/* 建立資料庫 */
CREATE DATABASE customer_db;
/* 建立資料表 */
CREATE TABLE customerinfor_tab
(
ci_no int(10) auto_increment PRIMARY KEY,
ci_firstname varchar(30),
ci_lastname varchar(30),
ci_mobile varchar(10)
)
/* 新增欄位 */
ALTER TABLE customerinfor_tab
ADD COLUMN ci_birthday DATE;
/* 修改欄位 */
ALTER TABLE customerinfor_tab
CHANGE COLUMN ci_birthday2
ci_birthday3 char(20)
sqlcode.sql
/* 新增一筆資料 */
INSERT INTO customerinfor_tab (`ci_firstname`,`ci_lastname`,`ci_mobile`,`ci_birthday`)
VALUES ('Stephen','Hu','0956152596','1987-05-13')
/* 修改資料 */
UPDATE customerinfor_tab
SET ci_firstname = 'Stephen',
ci_lastname = 'Lin'
WHERE ci_no = 5
/* 刪除一筆資料 */
DELETE
FROM customerinfor_tab
WHERE ci_no = 3 |