每一種語言都有自己的注釋方式,代碼量越多,代碼注釋的重要性也就越明顯。一般情況下,注釋可以出現(xiàn)在程序中的任何位置,用來向用戶或程序員提示或解釋程序的功能及作用。本文主要介紹MySQL
中的注釋。
1.字段注釋
create table test1( id int primary key comment 'user_id' ) ;
2.表注釋
create table test2( id int primary key, name varchar(20) not null )comment='table_comment';
3.單行注釋
a) 單行注釋可以使用#
注釋符,#
注釋符后直接加注釋內容。格式如下:
create table test3( id int primary key, name varchar(20) not null#偶只是一個單行屬性 );
b) 單行注釋可以使用--
注釋符,--
注釋符后需要加一個空格,注釋才能生效。格式如下:
create table test4( id int primary key, name varchar(20) not null -- 偶是一個--的單行屬性 school varchar(20) not null --偶是一個--的單行屬性(錯誤的注釋,因為--后面沒有空一格) );
4.多行注釋
create table test5( id int primary key, name varchar(30) not null/*鯤之大,不知其幾千里也, 一鍋燉不下,故有天眼*/ );
推薦:《mysql教程》