SQL語法簡介與範例應用學習知識庫:第三篇
[如何編寫自己欲新建立的資料庫內容教學:範例xxxx.txt]
SD_customers_DB.txt編寫範例應用內容註解說明(一):
在資料庫[SD_customers_DB.txt]中建立一個[SD_member]新資料表,
並將[SD_member]資料表中的[member_id]欄位設為主鍵,
指定了 NOT NULL 子句,char 資料類型就會是固定長度的資料類型,
varchar 資料類型是可變長度的資料類型。
SD_customers_DB.txt編寫範例應用內容註解說明(二):
NOT NULL 用來限制該欄位不能接受空值,
當某欄位限制為NOT NULL時,則在新增資料時該欄位一定要有值。
-------------------------------------------------------------
將NULL插入一個AUTO_INCREMENT欄位,則代表目前順序中的下一個號碼。
------------------------------------------------------------
PRIMARY KEY 用來保證欄位在資料表中的唯一性,
主鍵欄位中的每一筆資料在資料表中都必需是獨一無二的。
-------------------------------------------------------------
datetime:用來記錄日期/時間的資料型別。
-------------------------------------------------------------
/**************************************************/
/** SD_customers_DB.txt編寫範例應用內容: **/
/*************************************************/
/* 建立一個叫做 SD_customers_DB 的資料庫 */
create database SD_customers_DB;
/* 將 SD_customers_DB 資料庫設為作用資料庫 */
use SD_customers_DB;
create table SD_member
(
member_id int not null auto_increment primary key,
member_account char(15) not null,
member_password char(15) not null,
member_telephone char(15),
member_email varchar(20),
member_address char(50),
member_date datetime not null
)
character set utf8 collate utf8_general_ci;
/**************************************************/
留言列表