1.查看当前用户有哪些表
desc user_tables;
select table_name from user_tables;
2.根据已有的表创建新表
create table table_new as select col1,col2... from table_old;
3.重民名表
alter table tableName rename to new_tabaleName;
4.添加表字段
alter table tableName add (name varchar2(10));//多个字段逗号分割
5.删除表字段
alter table tableName drop column name;
6.修改字段(长度)
alter table tableName modify(name varchar2(11));//该变name的长度,无法改变类型。
7.修改字段名
alter table tableName rename column name to names;
8.创建视图
create view viewName as select x from cpb;
9.删除视图
drop view viewName;
10.修改字段值
update tableName set names='tomcat',score=20 where ...; //没有where 则修改所有
11.删除记录
delete from tableName where x=3;//没有where 则删除所有记录
truncate table tableName;//清空个所有数据,与delect 相比,无法回滚,但删除较快。
12.删除表
drop table tableName;
13.复制表结构
create table tableName as select * from b where 1>1;
14.复制表数据
insert into tableName(select * from b);
15.复制表结构和表数据
create table cpb as select * from b;
16.复制指定字段
create table cpb as select x from b;