-
RDMS
IMG_B5BC9174D201-2.jpeg 几个名词
-
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;
- 为列添加别名
可以使用中文,但是要用双引号括起来
- 使用distinct删除列中重复的数据
NULL也被当作一类数据,即distinct不忽略NULL。
distinct只能写在第一个列名前,这样的,意味着,组合列最为重复的区分条件。
select distinct type,date from product;
type and date 作为比较的对象。
and 优先级高于 or
只有select子句和having子句以及order by子句才可以使用聚合函数
select type,count(*) from product
where count(*) = 2 -- error
group by type;
