Bu konu, SQL Console sayfasında bir SQL ifadesi veya grafik kullanıcı arayüzü (GUI) kullanarak şemanın nasıl sorgulanacağını ve değiştirileceğini açıklar.
Önkoşullar
Bir veritabanının verilerini sorgulama, değiştirme ve dışa aktarma izinlerine sahip olmanız gerekir. Daha fazla bilgi için bkz. RAM izinlerini yönetme.
Kullanım notları
Şema değişiklikleri ilgili veritabanlarını ve iş süreçlerini etkileyebilir. Şema değişikliği yaparken dikkatli olun.
Şema sorgulama
Aşağıdaki örnekte test_table tablosunun şeması sorgulanmaktadır.
SQL ifadesi kullanarak şema sorgulama
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.
Tablo nesne bilgilerine göre tablo şemasını görüntüleme
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.
/********************************************/ /* DatabaseName = task_test */ /* TableName = test_table */ /********************************************/ CREATE TABLE `test_table` ( `id` int NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `age` int NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3 ;
GUI kullanarak şema değiştirme
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.
SQL ifadesi kullanarak şema değiştirme
-
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`;
GUI kullanarak şema değiştirme
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.
The dialog box displays the SQL statement generated from your actions, such as
ALTER TABLE test_table ADD COLUMN phone_number varchar(32) NOT NULL AFTER age;. Before you click Execute, confirm that the statement is correct.
İlgili kaynaklar
For information about how to make multiple changes to a schema at a time, see Data change.