標籤:
環境:win7 64位、mysql
適合閱讀者:對sql基本文法有一定瞭解
<建表語句>: create table <表名>( <列名> <類型> <資料行層級條件約束>[,<列名> <類型> <資料行層級條件約束>]... [,<表級約束>] );<類型>:int | char | date |....<資料行層級條件約束>:[not ]null | default <預設值> | primary key | auto_increment | comment ‘注釋內容‘ | unique | check <布林運算式> | ...<表級約束>:primary key(<列名>[,<列名>]...) | foreign key(<列名>[,<列名>]... ) references <表名> (<列名>[,<列名>]...)<建立視圖語句>: create view as <視圖名><查詢語句>; create view(<列名>[,<列名>]...) as <查詢語句>;<複合查詢語句>:<查詢語句>[union|intersect|except][ all]<查詢語句>;<巢狀查詢語句>:<查詢語句>(<查詢語句>);<查詢語句>: select *|<列名>{,<列明>} from <表明>{<表名>} [where <條件陳述式>] [Group by <列名> [having <分組條件陳述式>]] [Order By <列名2>[ asc | desc ]]; [語句]: 空|語句{語句}: 空|語句[,語句]··· <name>: <資料庫名>|<表名>|<列名><[distinct ]name[ 別名]>:可以給name消重或指定別名<條件陳述式>:<列名>|<函數> <謂詞><條件><謂詞>: 比較 =, >, <, >=, <=, !=, <>, !>, !< not + 上述比較子(例如not=) 確定範圍 between and, not between and 確定集合 in, not in 字元匹配 like, not like 空值 is null, is not null 多重條件 and, or 其它 not exists, exists, any, all <drop語句>:drop table|index|view <表名>|<索引名>|<視圖名>
<grant語句>:grant <許可權>[,<許可權>]… [on <物件類型> <對象名>] to <使用者>[,<使用者> …] [with grant option];
<許可權>:SELECT, INSERT, UPDATE(<列名>[,<列名>]...), DELETE, ALL PRIVIEGES, ALTER,INDEX, CREATETAB, CONNECT
<使用者>:userName|public
<revoke語句>:revoke <許可權>[,<許可權>]… [on <物件類型> <對象名>] from <使用者>[,<使用者> …]
參考:教學課件
mysql文法結構