get oracle list

object_list.sql:
set pagesize 0
set serveroutput on
set linesize 32767
set trimspool on
set heading on
set feedback off
set verify off
set echo off
set long 2000000000

spool .\[&_USER.]object_list.csv
SELECT ‘OBJECT名’ || ‘,’ || ‘OBJECTタイプ’ || ‘,’ || ‘状態’ FROM DUAL;
SELECT OBJECT_NAME || ‘,’ || OBJECT_TYPE || ‘,’ || STATUS FROM ALL_OBJECTS WHERE OWNER = ‘&_USER’ AND OBJECT_TYPE = ‘SYNONYM’ ORDER BY OBJECT_NAME;
SELECT OBJECT_NAME || ‘,’ || OBJECT_TYPE || ‘,’ || STATUS FROM ALL_OBJECTS WHERE OWNER = ‘&_USER’ AND OBJECT_TYPE = ‘TABLE’ ORDER BY OBJECT_NAME;
SELECT OBJECT_NAME || ‘,’ || OBJECT_TYPE || ‘,’ || STATUS FROM ALL_OBJECTS WHERE OWNER = ‘&_USER’ AND OBJECT_TYPE = ‘SEQUENCE’ ORDER BY OBJECT_NAME;
SELECT OBJECT_NAME || ‘,’ || OBJECT_TYPE || ‘,’ || STATUS FROM ALL_OBJECTS WHERE OWNER = ‘&_USER’ AND OBJECT_TYPE = ‘VIEW’ ORDER BY OBJECT_NAME;
SELECT OBJECT_NAME || ‘,’ || OBJECT_TYPE || ‘,’ || STATUS FROM ALL_OBJECTS WHERE OWNER = ‘&_USER’ AND OBJECT_TYPE = ‘PACKAGE’ ORDER BY OBJECT_NAME;
SELECT OBJECT_NAME || ‘,’ || OBJECT_TYPE || ‘,’ || STATUS FROM ALL_OBJECTS WHERE OWNER = ‘&_USER’ AND OBJECT_TYPE = ‘PACKAGE BODY’ ORDER BY OBJECT_NAME;
SELECT OBJECT_NAME || ‘,’ || OBJECT_TYPE || ‘,’ || STATUS FROM ALL_OBJECTS WHERE OWNER = ‘&_USER’ AND OBJECT_TYPE = ‘TRIGGER’ ORDER BY OBJECT_NAME;
spool off

spool .\[&_USER.]table_column_list.csv
SELECT ‘テーブル名’ || ‘,’ || ‘列名’ || ‘,’ || ‘データ型’ || ‘,’ || ‘長さ’ || ‘,’ || ‘小数部’ || ‘,’ || ‘NULL可’ FROM DUAL;
SELECT TABLE_NAME || ‘,’ || COLUMN_NAME || ‘,’ || DATA_TYPE || ‘,’ || NVL(DATA_PRECISION, CHAR_COL_DECL_LENGTH) || ‘,’ || DATA_SCALE || ‘,’ || NULLABLE FROM USER_TAB_COLUMNS ORDER BY TABLE_NAME,COLUMN_NAME;
spool off

spool .\[&_USER.]index_list.csv
SELECT ‘インデックス名’ || ‘,’ || ‘列名’ || ‘,’ || ‘インデックスタイプ’ || ‘,’ || ‘テーブル名’ || ‘,’ || ‘UNIQUE/NONUNIQUE’ || ‘,’ || ‘状態’ FROM DUAL;
SELECT
A.INDEX_NAME        || ‘,’ ||
B.COLUMN_NAME       || ‘,’ ||
A.INDEX_TYPE        || ‘,’ ||
A.TABLE_NAME        || ‘,’ ||
A.UNIQUENESS        || ‘,’ ||
—    A.TABLESPACE_NAME   || ‘,’ ||
—    A.TABLE_OWNER       || ‘,’ ||
A.STATUS
FROM
USER_INDEXES        A
, USER_IND_COLUMNS    B
WHERE
A.INDEX_NAME = B.INDEX_NAME
ORDER BY
A.TABLE_NAME
, A.UNIQUENESS DESC
, B.COLUMN_NAME;
spool off

spool .\[&_USER.]source.txt
SELECT TEXT FROM USER_SOURCE ORDER BY NAME,TYPE,LINE;
spool off

exit

Add a Comment

您的电子邮箱地址不会被公开。 必填项已用*标注