Mega Code Archive

 
Categories / Oracle PLSQL / Table
 

Create as select

SQL> SQL> SQL> create table employee(   2        employee_id number,   3        break_reason varchar2(100),   4        break_time interval day(1) to second(2)); Table created. SQL> SQL> insert into employee ( employee_id, break_reason, break_time )   2      values ( 100, 'C',   3               TIMESTAMP '2001-09-03 12:47:00.000000' -   4               TIMESTAMP '2001-09-03 13:13:00.000000' ); 1 row created. SQL> SQL> insert into employee ( employee_id, break_reason, break_time )   2      values ( 100, 'B',   3               TIMESTAMP '2001-09-03 13:35:00.000000' -   4               TIMESTAMP '2001-09-03 13:39:00.000000' ); 1 row created. SQL> SQL> insert into employee ( employee_id, break_reason, break_time )   2      values ( 100, 'P',   3               TIMESTAMP '2001-09-03 16:30:00.000000' -   4               TIMESTAMP '2001-09-03 17:00:00.000000' ); 1 row created. SQL> SQL> insert into employee ( employee_id, break_reason, break_time )   2      values ( 100, 'F',   3               TIMESTAMP '2001-09-03 17:00:00.000000' -   4               TIMESTAMP '2001-09-03 17:30:00.000000' ); 1 row created. SQL> SQL> select * from employee; EMPLOYEE_ID BREAK_REASON                   BREAK_TIME ----------- ------------------------------ ------------------------------         100 C                              -0 00:26:00.00         100 B                              -0 00:04:00.00         100 P                              -0 00:30:00.00         100 F                              -0 00:30:00.00 SQL> SQL> SQL> create table another_dept   2  as select *   3  from employee; Table created. SQL> SQL> SQL> select * from another_dept; EMPLOYEE_ID BREAK_REASON                   BREAK_TIME ----------- ------------------------------ ------------------------------         100 C                              -0 00:26:00.00         100 B                              -0 00:04:00.00         100 P                              -0 00:30:00.00         100 F                              -0 00:30:00.00 SQL> SQL> drop table another_dept; Table dropped. SQL> drop table employee; Table dropped. SQL>