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
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
In the navigation tree on the left of the SQLConsole tab, right-click the table that you want to check and click Object Information.
In the Create Statement section, you can view the statement that was used to create the table.
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
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
In the navigation tree on the left of the SQLConsole tab, right-click the target table and select Edit Table Structure.
In the left-side navigation pane, click Column Information.
On the Column Information tab, click New.
A new row appears. Enter relevant information in the new row and click Modify in the lower part of the tab.
In the Modify dialog box, click Execute.
References
For information about how to make multiple changes to a schema at a time, see Data change.