-
RDMS
IMG_B5BC9174D201-2.jpeg 幾個(gè)名詞
-
DDL:data definition language
- create
- drop
- alter
-
DML: data manipulate language
- select
- insert
- update
- delete
-
DCL: data control language
- commit
- rollback
- revoke
添加列
alter table <table> add <column>;
alter table <table> add (<column>,<column>,...)
eg:
alter table product add (product_name_pingyin varchar(100));
- 刪除一列
alter table <table> drop <column>;
eg:
alter table product drop product_name_pingyin;
- 變更表名
alter table product rename to product_tmp;
- 為列添加別名
可以使用中文,但是要用雙引號(hào)括起來
- 使用distinct刪除列中重復(fù)的數(shù)據(jù)
NULL也被當(dāng)作一類數(shù)據(jù),即distinct不忽略NULL。
distinct只能寫在第一個(gè)列名前,這樣的,意味著,組合列最為重復(fù)的區(qū)分條件。
select distinct type,date from product;
type and date 作為比較的對(duì)象。
and 優(yōu)先級(jí)高于 or
只有select子句和having子句以及order by子句才可以使用聚合函數(shù)
select type,count(*) from product
where count(*) = 2 -- error
group by type;
