一、DDL语言的学习
1.create关键字,用来创建表结构
/*格式如下:
create table tname(
colName dataType,
colName dataType,
………………
colName dataType
);
*/
2:alter,用来修改表结构
1)增加表的字段
--格式: alter table tname add (colName dataType);
--练习:为表temp_1增加个字段 tage 类型为number,长度为2
alter table temp_1 add (tage number(2));
2)删除表的字段
-- 格式: alter table tname drop column colName
-- 练习:删除temp_1表中的tage
alter table temp_1 drop column tage;
3)修改字段的名称
-- 格式: alter table tname rename column oldName to newName
-- 练习:将表temp_1的tname修改成name
alter table temp_1 rename column tname to name;
4)修改字段的数据类型
-- 格式:alter table tname modify colName dataType
-- 练习:修改temp_1表中的name 为varchar2(30);
alter table temp_1 modify name varchar2(30);
5)修改表名
-- 格式:rename oldTname to newTname
-- 练习:修改temp_1为temp_2;
rename temp_1 to temp_2;
6)删除表结构
-- 格式:drop table tname;
-- 练习:将temp_2删除
drop table temp_2;
7)查看表结构
-- 格式: desc tname;
-- 练习:创建temp_1,查看表结构
desc temp_1;