CREATE TABLE table_test_1 ( pkid NUMBER(1,0) NOT NULL , code VARCHAR2(2) NOT NULL );Verify table creation and examine its properties in the data dictionary:
SELECT table_name, tablespace_name, degree, logging, num_rows, blocks, avg_row_len FROM user_tables WHERE table_name = 'TABLE_TEST_1';Query result:
| TABLE_NAME | TABLESPACE_NAME | DEGREE | LOGGING | NUM_ROWS | BLOCKS | AVG_ROW_LEN | +--------------+--------------------+--------+---------+----------+--------+-------------+ | TABLE_TEST_1 | USERS | 1 | YES | (null) | (null) | (null) |Note:
CREATE TABLE table_test_2 AS SELECT pkid, code FROM table_test_1;Complex CTAS with Joins and Transformations:
CREATE TABLE table_test_3 AS SELECT t1.pkid, (t1.code || t2.code) AS code_new_name FROM table_test_1 t1 JOIN table_test_2 t2 ON t2.pkid = t1.pkid;
ALTER TABLE table_test_2 RENAME TO table_test_2_new_name;Important Considerations for Table Renaming:
DROP TABLE table_test_1;Recycle Bin Management:
DROP TABLE table_name PURGE;
to permanently drop the table and bypass the Recycle Bin.DROP TABLE table_test_1 PURGE;Drop table and all dependent constraints:
DROP TABLE table_test_1 CASCADE CONSTRAINTS;
NOLOGGING
option can improve the performance of bulk data operations such as CREATE TABLE AS SELECT, INSERT with direct-path, and bulk loads.
This option instructs Oracle not to write minimal information to the REDO LOG
file for certain operations, which can improve performance and save redo log space.
Note that NOLOGGING operations may affect database recovery.CREATE TABLE table_logging_1 ( pkid NUMBER(1,0) NOT NULL , code VARCHAR2(2) NOT NULL ) NOLOGGING;Note: The table structure creation is always logged; NOLOGGING affects subsequent DML operations like INSERT /*+ APPEND */.
ALTER TABLE table_logging_1 NOLOGGING; ALTER TABLE table_logging_1 LOGGING;
CREATE TABLE table_logging_2 NOLOGGING AS SELECT pkid, code FROM table_test_1;
CREATE TABLE table_parallel_1 ( pkid NUMBER(1,0) NOT NULL , code VARCHAR2(2) NOT NULL ) NOLOGGING PARALLEL 3;
ALTER TABLE table_parallel_1 PARALLEL 3; ALTER TABLE table_parallel_1 NOPARALLEL;
CREATE TABLE table_parallel_2 NOLOGGING PARALLEL 3 AS SELECT pkid, code FROM table_test_1;