oracle操作
时间:2021-07-01 10:21:17
帮助过:15人阅读
select table_name,degree
from user_tables;
--
设置并行
ALTER TABLE rsk_book_histogram PARALLEL 2;
--
取消并行
ALTER TABLE rsk_book_histogram NOPARALLEL;
--
删除表空间
DROP TABLESPACE TBNAME INCLUDING CONTENTS AND DATAFILES;
--
闪回
SELECT *
FROM etl_column AS OF TIMESTAMP to_timestamp(‘2017-11-10 14:05:00‘,
‘yyyy-mm-dd hh24:mi:ss‘)
--
查询死锁
select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id =
sess.sid;
select *
from v$session t1, v$locked_object t2
where t1.sid =
t2.SESSION_ID;
select *
from tran_bond_detail;
--
杀掉死锁
alter system kill session ‘sid,serial‘;
1.建立表空间,
create tablespace "NETHRA" DATAFILE
‘D:\DataBase\Oracle\iClass\iclass\iclass.DBF‘ SIZE 100M
AUTOEXTEND ON NEXT 10M
2.创建用户并授权
CREATE USER "NETHRA" PROFILE
"DEFAULT" IDENTIFIED BY
"nethra" DEFAULT TABLESPACE
"NETHRA" TEMPORARY TABLESPACE
"TEMP" ACCOUNT UNLOCK
GRANT "CONNECT" TO
"NETHRA"
GRANT "DBA" TO
"NETHRA
3.
exp nethra/nethra@iclass file=d:\iclass20160108.dmp full=
y
4.
imp nethra/nethra@iclass file=d:\iclass20160108.dmp full=
y
--1G=
1024MB
--1M=
1024KB
--1K=
1024Bytes
--1M=
11048576Bytes
--1G=
1024*11048576Bytes=
11313741824Bytes
SELECT a.tablespace_name "表空间名",
total "表空间大小",
free "表空间剩余大小",
(total - free)
"表空间使用大小",
total / (
1024 *
1024 *
1024)
"表空间大小(G)",
free / (
1024 *
1024 *
1024)
"表空间剩余大小(G)",
(total - free) / (
1024 *
1024 *
1024)
"表空间使用大小(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
5.
alter tablespace HRA_GF
add datafile ‘D:\DATABASE\ORACLE\HRA_DEV\GF_STG_TBS21.dbf‘ size 1024M autoextend on ;
6.查看主键索引
select a.constraint_name c, a.column_name
from user_cons_columns a, user_constraints b
where a.constraint_name =
b.constraint_name
and b.constraint_type =
‘P‘
AND B.owner =
‘{Holworth.Utility.HraUtility.GetDataBaseInfo(AppEnum.Web).user}‘
and a.table_name =
‘{targetTable}‘
7.添加主键约束
alter table {targetTable} add constraint pk_{targetTable.Substring(0, len)} primary key({IdField})
8.删除主键约束
alter table {targetTable} drop constraint {cname}
oracle操作
标签:dbf HERE 约束 ant div Owner space str traints