oracle常用语法
Posted 巍巍之道
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle常用语法相关的知识,希望对你有一定的参考价值。
oracle11g空表处理:
select ‘alter table ‘||table_name||‘ allocate extent;‘ from user_tables where num_rows=0;
然后将执行结果复制到另一个SQL窗口,并执行。
导出: exp test/[email protected]_name file=c:备份文件.dmp owner=user
导入: imp test/[email protected]_name file=c:备份文件.dmp fromuser=test touser=test
exp nempi/[email protected]/ptai file=d:empi.dmp owner=nempi
imp nempi/[email protected] file=D:NeusoftProjectN南京儿童医院empi.dmp fromuser=nempi touser=nempi
CREATE SEQUENCE emp_sequence --序列名
INCREMENT BY 1 -- 每次加几个
START WITH 1 -- 从1开始计数
NOMAXVALUE -- 不设置最大值
NOCYCLE -- 一直累加,不循环
CACHE 10;
imp hlyy/[email protected] file=d:hlyy.dmp fromuser=hlyy touser=hlyy
imp nhbi_work/[email protected] file=d:
hbi_work.dmp fromuser=nhbi_work touser=nhbi_work
exp hlyy/[email protected] file=d:hlyy.dmp owner=hlyy
exp nhbi_work/[email protected] file=d:
hbi_work.dmp owner=nhbi_work
imp hlyy_ods/[email protected] file=d:hlyy_ods.dmp fromuser=hlyy_ods touser=hlyy_ods ignore=y DESTROY=y
exp myqq/[email protected]/orcl file=d:myqq.dmp owner=myqq
imp myqq/[email protected] file=d:myqq.dmp fromuser=myqq touser=myqq
exp hlyy/[email protected] file=e:hlyy.dmp owner=(hlyy,hlyy_ods,hlyy_itf,nhbi_work)
/*分为四步 */
/*第1步:创建临时表空间 */
create temporary tablespace yuhang_temp
tempfile ‘D:oracledatayuhang_temp.dbf‘
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
/*第2步:创建数据表空间 */
create tablespace yuhang_data
logging
datafile ‘D:oracledatayuhang_data.dbf‘
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
/*第3步:创建用户并指定表空间 */
create user yuhang identified by yuhang
default tablespace yuhang_data
temporary tablespace yuhang_temp;
/*第4步:给用户授予权限 */
grant connect,resource,dba to yuhang;
exp kb/[email protected] file=d:kb.dmp owner=kb
imp kb/[email protected] file=C:UserswangwDesktopkbkb.dmp fromuser=kb touser=kb
--表空间
SELECT a.tablespace_name "表空间名",
round(total/(1024 * 1024 * 1024),4) "表空间大小",
round(free/(1024 * 1024 * 1024),4) "表空间剩余大小",
round((total - free)/(1024 * 1024 * 1024),4) "表空间使用大小",
round(total / (1024 * 1024 * 1024),4) "表空间大小(G)",
round(free / (1024 * 1024 * 1024),4) "表空间剩余大小(G)",
round((total - free) / (1024 * 1024 * 1024),4) "表空间使用大小(G)",
round((total - free) / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
order by round((total - free) / total, 4) * 100 desc
--表空间是否自增长
select file_id,file_name,tablespace_name,autoextensible,increment_by from dba_data_files order by file_id desc;
--CDR加表空间
alter tablespace CDRDATA add datafile ‘D:APPADMINISTRATORORADATAORCLCDRCDRDATA7.DBFF‘ size 30G autoextend on next 30M;
以上是关于oracle常用语法的主要内容,如果未能解决你的问题,请参考以下文章