Tibero 주요 Query

테이블 정보 조회

SELECT A.COLUMN_NAME, DATA_TYPE, DECODE(DATA_TYPE, 'VARCHAR', DATA_LENGTH) DATA_LENGTH, COMMENTS 
FROM USER_TAB_COLUMNS A, USER_COL_COMMENTS B
WHERE A.TABLE_NAME = '[Table_Name]'
AND A.TABLE_NAME = B.TABLE_NAME
AND A.COLUMN_NAME = B.COLUMN_NAME
ORDER BY COLUMN_ID

테이블 사용량 조회

SELECT OWNER, SEGMENT_NAME, SEGMENT_TYPE, SUM(BYTES)/1024/1024 AS MB
FROM DBA_SEGMENTS
WHERE SEGMENT_TYPE='TABLE' AND SEGMENT_NAME='[TABLE_NAME]'
GROUP BY OWNER, SEGMENT_NAME, SEGMENT_TYPE;

테이블 복사

  • Schema + Data
CREATE TABLE [NEW_TABLE_NAME] AS SELECT * FROM [OLD_TABLE_NAME];
CREATE TABLE [NEW_TABLE_NAME] AS SELECT * FROM [OLD_TABLE_NAME] WHERE [Condition];
  • Schema
CREATE TABLE [NEW_TABLE_NAME] AS SELECT * FROM [OLD_TABLE_NAME] WHERE 1=2;
  • Data
INSERT INTO [TARGET_TABLE_NAME] SELECT * FROM [SOURCE_TABLE_NAME];
INSERT INTO [TARGET_TABLE_NAME] SELECT * FROM [SOURCE_TABLE_NAME] WHERE [Condition];

테이블 이름 변경

ALTER TABLE [OLD_TABLE_NAME] RENAME TO [NEW_TABLE_NAME];

테이블 삭제

DELETE FROM [TALBE_NAME];