MySQL 建立資料表

2021-07-31 10:39:10 字數 574 閱讀 9827

mysql 建立資料表

建立mysql資料表需要以下資訊:

1.表名

2.表欄位名

3.定義每個表字段

語法

以下為建立mysql資料表的sql通用語法:

create table 《表名》 (《列定義》 );

其中:1.《表名》最多可有128個字元,如s,sc,c等,不允許重名

2.《列定義》的書寫格式為,《列名》《資料型別》[default] 。

3.default,若某欄位設定有預設字段值,則該字段未被輸入資料 時,以該預設值自動填入該欄位。

以下例子中我們將在 school資料庫中用sql建立乙個學生表s表:

create

table s(

sno char(6),

sn varchar(8),

*** char(2) default

'男',

age int ,

dept varchar(20)

)

建立mysql資料表

mysql建表語句 create table if not exists db name.table name colunum1 date not null comment 列欄位說明 colunum2 int 11 not null comment 列欄位說明 colunum3 int 11 no...

MYSQL 建立資料表

rdbms即關聯式資料庫管理系統 relational database management system 的特點 rdbms術語 資料庫 一些關聯的表的集合 資料表 資料的矩陣。等同於簡單的電子 列 同一類資料 行 一組相關資料,稱為乙個記錄 冗餘 儲存量被資料,使系統速度更快。主鍵 唯一。外來...

MySQL 建立資料表

建立mysql資料表需要以下資訊 以下為建立mysql資料表的sql通用語法 create table table name column name column type 以下例子將在 runoob 資料庫中建立資料表runoob tbl runoob tbl runoob id int not ...