MySQLクエリーコメント情報
2082 ワード
MySQLクエリーの変更
##MySQLの下で次の表文を実行した後.データ辞書から、このテーブルのフィールドに関する情報を取得するにはどうすればいいですか?
答えは次のとおりです.
補足:http://blog.knowsky.com/259955.htm参考ドキュメントはあまり力が入らないでしょう.表の注釈とフィールドの注釈の資料が不完全です.1テーブル作成時にコメントを書く
2表のコメントの変更
3フィールドのコメントの変更
4表注記の表示方法
5フィールドコメントの表示方法
##MySQLの下で次の表文を実行した後.データ辞書から、このテーブルのフィールドに関する情報を取得するにはどうすればいいですか?
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table(
Test_ID int NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT ' ( )',
Test_Key varchar(10) NOT NULL COMMENT ' ',
Test_Value varchar(20) NOT NULL COMMENT ' ',
Test_Type int NOT NULL COMMENT ' ',
Test_BelongTo int COMMENT ' ' ,
Test_Grade int DEFAULT 1 COMMENT ' ',
Test_Remark varchar(50) COMMENT ' ',
Test_Visible bit DEFAULT 1 COMMENT ' '
)
COMMENT = ' ';
答えは次のとおりです.
SELECT
column_name AS ' ',
data_type AS ' ',
character_maximum_length AS ' ',
numeric_precision AS ' ',
numeric_scale AS ' ',
is_nullable AS ' ',
CASE
WHEN extra = 'auto_increment' THEN 1
ELSE 0
END AS ' ',
column_default AS ' ',
column_comment AS ' '
FROM
Information_schema.columns
WHERE
table_Name='test_table';
補足:http://blog.knowsky.com/259955.htm参考ドキュメントはあまり力が入らないでしょう.表の注釈とフィールドの注釈の資料が不完全です.1テーブル作成時にコメントを書く
create table test1
(
field_name int comment ' '
)comment=' ';
2表のコメントの変更
alter table test1 comment ' ';
3フィールドのコメントの変更
-- :
alter table test1 modify column field_name int comment ' ';
4表注記の表示方法
-- SQL
show create table test1;
--
use information_schema;
select *
from TABLES
where TABLE_SCHEMA='my_db' and TABLE_NAME='test1'
5フィールドコメントの表示方法
-- show
show full columns from test1;
--
select * from COLUMNS where TABLE_SCHEMA='my_db' and TABLE_NAME='test1'