oracle 常见命令

查表空间磁盘参数
ACCEPT sth PROMPT ‘请输入要查看的表空间名:’
col tablespace_name for a15
select tablespace_name,initial_extent,next_extent,max_extents,pct_increase,min_extlen
from dba_tablespaces
where lower (tablespace_name) like ‘%&sth%’
/
查表空间的类型
ACCEPT sth PROMPT ‘请输入要查询的表空间名称:’
select tablespace_name,status,contents
from dba_tablespaces
where lower(tablespace_name) like ‘%&sth%’
/
查表空间对应的数据文件
ACCEPT sth PROMPT ‘请输入要查询表空间的名称:’
col file_name for a30
select tablespace_name,file_id,file_name,autoextensible
from dba_data_files
where lower(tablespace_name) like ‘%&sth%’
/
查对象创建日期
ACCEPT object_name PROMPT ‘请输入对象名(table,view,index,sequence,synonym):’
select object_name,object_type,created,last_ddl_time,status
from user_objects
where lower(object_type)= ‘&object_name’
/
查临时表空间对应的数据文件
col file for a30
col tablespace for a25
select f.file#,t.ts#,f.name “File”,t.name “Tablespace”
from v t e m p f i l e f , V tempfile f,V tempfilef,Vtablespace t
where f.ts# = t.ts#
/
查默认表空间
col property_name for a20
col property_value for a20
col description for a20
select *
from database_properties
where property_name like ‘DEFAULT%’
/
查同义词信息
select synonym_name,table_owner,table_name
from user_synonyms
/
查序列号信息
select sequence_name,min_value,max_value,increment_by,last_number
from user_sequences
/
查用户下的所有表
select table_name from user_tables
/
创表空间
ACCEPT tablespace_name PROMPT ‘请输入要创建的表空间名称:’
ACCEPT add PROMPT ‘请输入数据文件地址:’
ACCEPT size PROMPT ‘请输入数据文件大小:’
ACCEPT usize PROMPT ‘请输入区段extent的大小:’
create tablespace &tablespace_name
datafile ‘&add’
size &size
extent management local
uniform size &usize
/
创还原表空间
ACCEPT sth1 PROMPT ‘请输入要创建还原表空间名称:’
ACCEPT sth2 PROMPT ‘请输入数据文件地址:’
ACCEPT sth3 PROMPT ‘请输入数据文件大小:’
create undo tablespace &sth1
datafile ‘&sth2’
size &sth3
/
创临时表空间
ACCEPT sth1 PROMPT ‘请输入要创建临时表空间名称:’
ACCEPT sth2 PROMPT ‘请输入临时数据文件地址:’
ACCEPT sth3 PROMPT ‘请输入临时数据文件大小:’
ACCEPT sth4 PROMPT ‘请输入区段extent的大小:’
create temporary tablespace &sth1
tempfile ‘&sth2’
size &sth3
extent management local
uniform size &sth4
/
创同义词
ACCEPT s PROMPT ‘请输入简称:’
ACCEPT sss PROMPT ‘请输入要替代的名称:’
create synonym &s
for &sss
/
创序列号
ACCEPT sequence_name PROMPT ‘请输入序列号名:’
ACCEPT start_number PROMPT ‘请输入开始数目:’
ACCEPT increment_number PROMPT ‘请输入增幅:’
ACCEPT maxvalue PROMPT ‘请输入能增长的最大值:’
create sequence &sequence_name
start with &start_number
increment by &increment_number
maxvalue &maxvalue
nocycle
/
改默认临时表空间
ACCEPT sth PROMPT ‘请输入默认临时表空间为:’
alter database default temporary tablespace &sth
/
改数据文件为自动扩展
ACCEPT sth1 PROMPT ‘请输入要扩展的完整的文件名:’
alter database datafile
‘&sth1’ autoextend on
next 1M
/
改序列号增幅
ACCEPT name PROMPT ‘请输入要改的序列号名:’
ACCEPT increment PROMPT ‘请输入修改后的增幅为:’
alter sequence &name
increment by &increment
/
改序列号最大值
ACCEPT name PROMPT ‘请输入要改的序列号名:’
ACCEPT maxvalue PROMPT ‘请输入修改后的最大值为:’
alter sequence &name
maxvalue &maxvalue
/
改序列号最小值
ACCEPT name PROMPT ‘请输入要改的序列号名:’
ACCEPT minvalue PROMPT ‘请输入修改后的最小值为:’
alter sequence &name
minvalue &minvalue
/
删表空间
ACCEPT sth1 PROMPT ‘请输入要删除表空间名:’
drop tablespace &sth1
/
删表空间及数据文件
ACCEPT sth1 PROMPT ‘请输入要删除的表空间名称(包括数据文件):’
drop tablespace &sth1 including contents and datafiles
/
删同义词
ACCEPT s PROMPT ‘请输入要删除同义词名:’
drop synonym &s
/
删序列号
ACCEPT sequence_name PROMPT ‘请输入要删除序列号名:’
drop sequence &sequence_name;

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值