oracle 常用命令

本文提供了一系列Oracle数据库管理脚本,包括生成删除所有表及序列的SQL语句、创建及删除表空间、创建用户和授权等操作。适用于数据库管理及迁移场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

生成删除所有表语句
select 'drop table '||table_name||' cascade constraints;' from user_tables;

 

生存删除所有sequence


select 'drop sequence '||sequence_name||';' from user_sequences;

创建表空间

create tablespace 空间名 datafile'C:\Oracle\product\10.2.0\oradata\test\test.dbf' size 100M;

创建用户

create user 帐号 identified by 密码 default tablespace 空间名;

给用户授权

grant connect,resource to test;
grant dba to test;

删除表空间

DROP TABLESPACE 空间名 INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;  

超出打开游标的最大数

alter system set open_cursors=10000 scope=both;

show parameter open_cursors;  

VBO-4562:无法删除表。ORA-38301:无法对回收站中的对象执行DDL/DML

purge recyclebin;

更新sequence值的动态sql语句

--导出之前把该语句执行一遍,复制执行结果,然后在导入后的数据库中删除sequence,再执行该语句.
select 'create sequence '||sequence_name||    
       ' minvalue '||min_value||    
       ' maxvalue '||max_value||    
       ' start with '||(last_number+1000000)||    
       ' increment by '||increment_by||    
       (case when cache_size=0 then ' nocache' else ' cache '||cache_size end) ||';'   
from user_sequences 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值