create table mytest(id varchar2(2 char),name varchar2(3 char));insert into mytest(id,name) values('01','tom');select * from mytest;update mytest set name='mm' where id='03';delete from mytest where id='03';alter table mytest add (address varchar2(100 char));alter table mytest rename column address to addr;
alter table mytest modify address varchar2(200 char);alter table mytest drop (addr);alter table mytest rename to mytest2;delete from mytest;--删除数据,可回滚
truncate table mytest;--删除数据,不可回滚,并重置计数器drop table mytest;--删除表,可恢复(flashback table mytest to before drop )
drop table mytest purge;--删除表,无法恢复alter table mytest read only;--只读
alter table mytest read write;--恢复读写select table_name from user_tables;desc:降序 asc:升序(默认)
select * from mytest order by id desc;select sex from mytest group by sex;create table mytest_new as select * from mytest;--备份表结构和数据
create table mytest_new as select * from mytest where 1=2; --只备份表结构
insert into mytest_new select * from mytest;--只备份表数据 alter table mytest add constraint name primary key(name); alter table mytest drop constraint id;create index index_name on table(column_name1,column_name2);drop index index_name;create synonym tablenameB for 数据库名字.tablenameA;drop synonym tablenameB;