表の一覧 †
select table_name from user_tables order by table_name;
表の項目一覧 †
desc <表名>;
インデックスの一覧 †
select index_name from user_indexes order by index_name;
select TABLE_NAME || ' ' || index_name || ' ' || UNIQUENESS from user_indexes order by index_name;
指定した表のインデックス詳細表示 †
select TABLE_NAME, INDEX_NAME, column_name from user_ind_columns where TABLE_NAME='<表名>';
select TABLE_NAME || ' ' || INDEX_NAME || ' ' || column_name from user_ind_columns order by TABLE_NAME, INDEX_NAME, column_name;
ユーザ一覧 †
select username from user_users;
データベースの文字コード †
select * from NLS_DATABASE_PARAMETERS where PARAMETER = 'NLS_NCHAR_CHARACTERSET';
表のコピー †
create table <新表名> as select * from <旧表名>;
表名の変更 †
create table <新表名> as select * from <旧表名>;
drop table <旧表名>;
表を別のORACLEへ持って行く †
exp "<username>/<password> file=exp01.dmp tables=(JOB, TOKUIDB, TOUR_JOHO)"
imp "<username>/<password> file=exp01.dmp tables=(JOB, TOKUIDB, TOUR_JOHO)"
表、カラム、定義の一覧をまとめて表示 †
SET SERVEROUTPUT ON SIZE 1000000;
set serveroutput on;
declare
cursor cu is select
lower(table_name) as テーブル名,
column_name as 項目名,
lower(data_type) as 項目タイプ,
nvl(data_precision, char_col_decl_length) as 長さ,
data_scale as 小数部
from user_tab_columns
order by table_name, column_id;
begin
-- 項目定義表示
for cu_rec in cu loop
dbms_output.put_line(
cu_rec.テーブル名 || ' ' ||
cu_rec.項目名 || ' ' ||
cu_rec.項目タイプ || ' ' ||
to_char(cu_rec.長さ, '99999') || ' ' ||
to_char(cu_rec.小数部, '99999')
);
end loop;
dbms_output.put_line ('===========================================================================');
end;
/
一時表領域の使用率 †
SELECT dt.file_name, dt.tablespace_name,
to_char(dt.bytes / 1024, '99999990.000') file_kbytes,
to_char(t.bytes_cached / 1024, '99999990.000') used_kbytes,
to_char(t.bytes_cached / dt.bytes * 100, '990.00') || '%' capacity
FROM sys.dba_temp_files dt, v$temp_extent_pool t, v$tempfile v
WHERE t.file_id(+)= dt.file_id AND dt.file_id = v.file#;