常用sql语句(备忘录)

1、删除表中的列 、删除表中的行:

alter table pmart_per.dm_ty_person_num_important_factor drop column factor_num

删除表dm_ty_person_num_important_factor中的factor_num

delete from pmart_per.dm_ty_person_num_predict_num
where create_date='2020-06-03'

删除表pmart_per.dm_ty_person_num_predict_num中符合where条件的行

2、删除表:

drop table  dm_ty_person_num_important_factor

删除表dm_ty_person_num_important_factor

3、修改表名

alter table 表名 rename to 新表名

4、更改字段的名字

alter table 表名 rename 字段名 to 新字段名

5、更改字段类型

alter table dbo.titemtype alter column id type integer using to_number(id,'9');

7、给用户赋予权限

grant select on pmart_per.dm_ty_person_num_zs_w to yonghu

给用户yonghu赋予表pmart_per.dm_ty_person_num_zs_w的查询权限

你可能感兴趣的:(数据库)