重庆协创Oracle培训中心与您分享数据定义语言和数据操纵语言。
一、数据定义语言
操作表的命令:
create table、alter table、truncate table、drop table。
修改表的命令:
alter table stu_table rename to stu_tbl;——修改表名
alter table stu_tbl rename column stu_sextosex;——修改列名
alter table stu_tbl modify(stu_name varchar2(2));——更改列的数据类型
alter table stu_tbl add(stu_name number);——添加新列
alter table stu_tbl drop(age);——删除列
alter table stu_tbl add constraint pk_stu_tbl primary key(id);——添加约束
二、数据操纵语言
select,update,delete,insert。
利用现有的表创建表
create table stu_tbl_log as select id,stu_name,stu_age from stu_tbl;——选择无重复的行
select distinct stu_name from stu_tbl;——插入来自其他表中的记录
insert into stu_tbl_log select id,stu_name,stu_age from stu_tbl;