sql ORACLE DDL发电机

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql ORACLE DDL发电机相关的知识,希望对你有一定的参考价值。

select
case
  when b.table_name is null then
     'unindexed'
  else
     'indexed'
end as status,
  a.table_name      as table_name,
  a.constraint_name as fk_name,
 a.fk_columns      as fk_columns,
 b.index_name      as index_name,
 b.index_columns   as index_columns
from
(
  select 
   a.table_name,
  a.constraint_name,
  listagg(a.column_name, ',') within
group (order by a.position) fk_columns
from
  dba_cons_columns a,
  dba_constraints b
where
  a.constraint_name = b.constraint_name
and 
  b.constraint_type = 'R'
and 
  a.owner = '__OWNER_NAME__'
and 
  a.owner = b.owner
group by 
  a.table_name, 
  a.constraint_name
) a
,(
select 
  table_name,
  index_name,
  listagg(c.column_name, ',') within
group (order by c.column_position) index_columns
from
  dba_ind_columns c
where 
  c.index_owner = '__OWNER_NAME__'
group by
  table_name, 
  index_name
) b
where
  a.table_name = b.table_name(+)
and 
  b.index_columns(+) like a.fk_columns || '%'
order by 
  1 desc, 2;
CREATE USER __USER_NAME__
IDENTIFIED BY __USER_PASSWORD__
DEFAULT TABLESPACE __TABLE_SPACE_NAME_
TEMPORARY TABLESPACE temp
QUOTA UNLIMITED ON __TABLE_SPACE_NAME_;

GRANT CREATE SESSION TO __USER_NAME__;
GRANT CREATE TABLE TO __USER_NAME__;
GRANT CREATE VIEW TO __USER_NAME__;
GRANT CREATE TRIGGER TO __USER_NAME__;
GRANT CREATE PROCEDURE TO __USER_NAME__;
GRANT CREATE SEQUENCE TO __USER_NAME__;
GRANT CREATE SYNONYM TO __USER_NAME__;
GRANT CREATE ANY DIRECTORY TO __USER_NAME__;
-- `Enable` script generator.
-- Must be run before disable. This will ensure you donot enable any already disabled key while restoring

SELECT 
'ALTER TABLE ' || OWNER || '.' || table_name || ' enable CONSTRAINT ' || constraint_name || ';'
FROM dba_constraints WHERE constraint_type = 'R' and status = 'ENABLED' AND OWNER='__OWNER_NAME__';

--`Disable` script generator
select 
'ALTER TABLE ' || OWNER || '.' || table_name || ' disable CONSTRAINT ' || constraint_name || ';'
from dba_constraints where constraint_type = 'R' and status = 'ENABLED' AND OWNER='__OWNER_NAME__';

以上是关于sql ORACLE DDL发电机的主要内容,如果未能解决你的问题,请参考以下文章

Oracle SQL语言DDL和对象管理_超越OCP精通Oracle视频教程培训27

oracle ddl语句用啥编辑

ORACLE SQL基础—DDL语言 礼记八目 2017-12-23 21:26:21

Oracle_SQL DDL 表和约束

hibernate.hbm2ddl.auto + Oracle 中的自定义 sql 类型

创建可重新运行的 Oracle DDL SQL 脚本