一、DML語句簡介
·DML(data definition language) 數據操作語句,包括create,drop,alter
二、create
1.創建數據庫:語法 create database 庫名
2.創建表:語法:crate table 表名
3.創建索引:
(1)創建普通索引:語法:create index 索引名 on 表名(列名)
(2)創建唯一索引:語法:create unique index 索引名 on 表名(列名)
三、alter
1.為表增加列 語法:alter table 表名 add 列名(也可指定字符長度)
2.刪除表中的某一列 語法: alter table 表名 drop 列名
3.修改列的字符長度或類型或重命名類名 語法:alter table 表名 change 原來的列 新的列 新的字符長度
4.修改表名 語法;alter table 表名 rename 新表名
5.刪除表中主鍵 語法:alter table 表名 drop primary key
6.為表添加主鍵 語法:alter table 表名 add constraint 主鍵名 primary key(列名)
7.添加索引:alter table 表名 add index 索引名(列名)
8.添加唯一索引 語法;alter table 表名 add unique index 索引名(列)
9.刪除索引語法;alter table 表名 drop index 索引名
10.修改字段數據類型 alter table 表名 modify 字段 數據類型
四、drop
1.刪除表 語法:drop table 表名
2.刪除庫名 語法:drop database 庫名