create table mytable( myid char(10), myname varchar2(10) default ‘myname’, myage number(3,0) );
desc mytable;
create table newTable(newId, newName, newAge) as (select myid, myname, myage from mytable);
desc newTable
– 在表名后定义新表的列名 – 顶顶一的列名与查询中的列名一一对应 有先后顺序 – 也可以直接省略列名 那么新创建的表的列名 是和查询的列名一样的
– 添加一列 – 添加 学号列 alter table newTable add sno char(12); desc newTable
– 注意 – 1 如果表中已经含有数据 类型是不能进行更改的 长度只能变大 – 2 默认值 只对新添加的数据 有效 alter table newTable modify sno char(3); insert into scott.newTable values (1,‘kongge’,12,‘1’); alter table newTable modify sno char(10);
alter table newTable drop column sno; desc newTable
rename newTable to new_table;
alter table new_table rename column newId to new_new_id desc new_table
– 一般用于将测试数据进行删除 truncate table new_table;
drop table new_table;