All Products
Search
Document Center

Data Management:Query and change a schema

Last Updated:Oct 13, 2023

This topic describes how to query and change a schema by using an SQL statement or the graphical user interface (GUI) on the SQL Console page.

Prerequisites

You have the permissions to query, modify, and export the data of a database. For more information, see Manage RAM permissions.

Usage notes

Schema changes may affect relevant databases and business. Proceed with caution when you change a schema.

Query a schema

The schema of the test_table table is queried in the following example.

Query a schema by using an SQL statement

  1. Go to the SQLConsole tab.

  2. On the SQLConsole tab, double-click the table name. The system automatically generates an SQL statement to query the schema of the table. Click Execute.

View the table schema based on the object information of a table

  1. Go to the SQLConsole tab.

  2. In the navigation tree on the left of the SQLConsole tab, right-click the table that you want to check and click Object Information.

    image.png
  3. In the Create Statement section, you can view the statement that was used to create the table.

    image.png

Change a schema by using the GUI

The Phone_number column is added to the test_table table in the following steps. On the SQLConsole tab, you can perform operations including adding foreign key indexes and modifying the storage engine.

Change a schema by using an SQL statement

  1. Go to the SQLConsole tab.

  2. On the SQLConsole tab, enter an SQL statement to change the schema of the table and click Execute.

    ALTER TABLE `test_table` 
     ADD COLUMN `phone_number` varchar(32) NOT NULL COMMENT 'phone_number' AFTER `age`;

Change a schema by using the GUI

  1. Go to the SQLConsole tab.

  2. In the navigation tree on the left of the SQLConsole tab, right-click the target table and select Edit Table Structure.

  3. In the left-side navigation pane, click Column Information.

  4. On the Column Information tab, click New.

  5. A new row appears. Enter relevant information in the new row and click Modify in the lower part of the tab.

  6. In the Modify dialog box, click Execute.

    image.png

References

For information about how to make multiple changes to a schema at a time, see Data change.