oracle数据库基本语句

备份数据库

  • 导出用户的表 :  exp username/password@orcl file=c:\backup.dmp owner=(system,sys)

  • 导出指定的表 :  exp username/password@orcl file=c:\back.dmp tables=(xxx,'表名')
  • 按过滤条件导出: exp usname/pd@orcl file=d:\xxx tables=(xxx) query=\" where fields1 like 'fg%'\"  导出时如果要压缩 加 compress=y ;如果需要日志 log=c:\log.txt
  • 备份远程服务器的数据库: exp username/pd@ip:xxxx file=xxx。dmp full=y

数据库还原

  • 完全还原: imp us/pd@orcl file=xxxx.dmp full=y ignore=y log=xxxx.txt
  • 导入制定表: imp us/pd@orcl file=xxx.dmp tavles=(xxx,xxx)
  • 还原到远程服务器: imp us/pd@ip:port file=xxx.dmp full=y

表操作

  • 创建表 create table tablename (age int,name String ……)
  • 删除表 drop table tablename
  • 重命名表 alter table 表名 rename to 新表名
  • 增加字段 alter table tablename add (ID int default '空' not null)
  • 修改字段 alter table tablename modify (ID varchar(4))
  • 重命名字段 alter table tablename rename column 列名 to 新列名
  • 删除字段 alter table tablename drop column 字段名
  • 添加主键 alter table tablename add primary key(col)
  • 删除主键 alter table tablename drop primary key(col)
  • 创建索引 create index idxname on tabname(col)

删除索引 drop index indexname (索引是不能改变的,再更改之前必须删除之前的索引 新建)

 

操作数据

  • 数据查询 select * from where xxx order by xxx desc/asc
  • 插入数据 insert into 表名() values ()
  • 更新数据 update 表名 set col=val where xxx=xxx
  • 删除数据 delete from 表名 where xxx=xxx
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值