oracle数据库基本语句:
1、创建数据库;
2、删除数据库;
3、备份数据库;
4、数据库还原;
5、重命名表;
6、修改字段;
7、删除索引;
创建
create database databasename
删除
drop database dbname
完全备份
exp demo/demo@orcl buffer=1024 file=d:back.dmp full=y
备份system和sys用户的表
exp demo/demo@orcl file=d:backup1.dmp owner=(system,sys)
备份指定表
exp demo/demo@orcl file=d:backup2.dmp tables=(teachers,students)
备份恢复
imp demo/demo@orcl file=d:back.dmp full=y ignore=y log=D:implog.txt
恢复指定表
imp demo/demo@orcl file=d:backup2.dmp tables=(teachers,students)
增加字段
alter table tablename add (ID int);
alter table tablename add (ID varchar2(30) default '空' not null);
修改字段
alter table tablename modify (ID number(4));
数据复制
insert into table1 (select * from table2);
字段改名
alter table tablename rename column ID to newID;
删除字段
alter table tablename drop column ID;
添加主键
alter table tabname add primary key(col)
删除主键
alter table tabname drop primary key(col)
创建索引
create [unique] index idxname on tabname(col….)
删除索引
drop index idxname
插入
insert into 表名(列) values(对应的值);
insert into test(id,name) values(2,'lisi');
更新
update test set age =20;
删除表
truncate table 表名 删除表中的数据,无法回滚的
drop table 表名 删除表,内容连带结构一起删除;