View common statements such as Oracle_table names, field names, comments, processes, and process killing

-- View all tables under this user in the ORACLE database
SELECT table_name FROM user_tables;

-- View all tables under all users in the ORACLE database
select user,table_name from all_tables;

-- View all columns under this user in the ORACLE database
select table_name,column_name from user_tab_columns;

-- View all columns under this user in the ORACLE database
select user, table_name, column_name from all_tab_columns;

-- View the sequence number in the ORACLE database
select * from user_sequences;

-- All the above objects can be obtained through the following SQL statement
-- Query all user-generated ORACLE objects
SELECT * FROM user_objects;

-- View comments on all tables in the ORACLE database
select table_name,comments from user_tab_comments;

-- View comments on all columns in the ORACLE database
select table_name,column_name,comments from user_col_comments;

-- Add ORACLE comments to the table
COMMENT ON TABLE aa10 IS 'system parameter table';

-- Add ORACLE comment
COMMENT ON COLUMN aa10.aaa100 IS 'parameter category';

-- Check the attributes of the columns in the table, including data type, whether it is not empty, etc.
DESC aa10;
-- Use the system table to check the attributes of the columns in the table, including the data type, whether it is not empty, etc.
SELECT table_name, COLUMN_ID, column_name, data_type, data_length, DATA_PRECISION,NULLABLE
FROM user_tab_columns
ORDER BY table_name,COLUMN_ID;


-- Check the database space occupied by tables and indexes in the database
SELECT * FROM user_segments;

-- Check the number of records in all tables
CREATE TABLE table_count(table_name VARCHAR2(50),columns NUMBER(20));
-- Run the following statement through PB to get the result set, execute the result set under PB, and finally submit
select ' insert into table_count values('''||table_name||''', (select count(1) from '||table_name||'));//'||comments from user_tab_comments; -- All table records
are SELECT * FROM table_count
;

// Synchronize the comments of the ORACLE database to the PB code start
DELETE FROM PBCATCOL WHERE PBC_TNAM LIKE '%';
DELETE FROM PBCATTBL WHERE PBT_TNAM LIKE '%';


INSERT INTO PBCATTBL
( PBT_TNAM,
PBT_OWNR ,
PBT_CMNT)
SELECT ALL_TAB_COMMENTS.TABLE_NAME,
ALL_TAB_COMMENTS.OWNER,
ALL_TAB_COMMENTS.COMMENTS
FROM ALL_TAB_COMMENTS
WHERE ALL_TAB_COMMENTS.OWNER = 'LH'
AND TABLE_NAME LIKE '%';


// Synchronize field name

INSERT INTO PBCATCOL
( PBC_TNAM,
PBC_OWNR,
PBC_CNAM,
PBC_LABL,
PBC_CMNT,
PBC_HDR)
SELECT ALL_COL_COMMENTS.TABLE_NAME,
ALL_COL_COMMENTS.OWNER,
ALL_COL_COMMENTS.COLUMN_NAME,
ALL_COL_COMMENTS.COMMENTS ,
ALL_COL_COMMENTS.COMMENTS ,
ALL_COL_COMMENTS.COMMENTS
FROM ALL_COL_COMMENTS
WHERE ALL_COL_COMMENTS.OWNER = 'LH'
AND TABLE_NAME LIKE '%';

COMMIT;
-- Synchronize the comments of the ORACLE database to PB. End of code


--将PB注释同步到ORACLE中
select 'comment on table '||pbt_tnam||' is '''||pbt_cmnt||''';' from pbcattbl where pbt_tnam not like 'PB%'
UNION
select 'comment on column '||pbc_tnam||'.'||pbc_cnam||' is '''||pbc_cmnt||''';' from pbcatcol where pbC_tnam not like 'PB%';


--查进程
select object_id,session_id,locked_mode from v$locked_object;

select t2.username,t2.sid,t2.serial#,t2.logon_time
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.logon_time;

--Kill process
alter system kill session '3,6666';

Guess you like

Origin blog.csdn.net/caryxp/article/details/132753382