Create table based on another table

How to create table emp1 based on emp, except comm column?

Questions by vijaychakaravarthy

Showing Answers 1 - 7 of 7 Answers


It can be done by create / insert statement as follows ;

   If 'EMP' is the table with structure

   ENO          VarChar(12)
   DoJ           date
   ESAL         Numerix
   COMM       numeric 

   Now , we can create EMP1 table using EMP Table and exclude the field 'COMM' as

    create table EMP1 as select ENO, DoJ, ESAL from EMP where 1<0 ( this false condition will copy the structure only , not rows from EMP table)

  Was this answer useful?  Yes

CREATE TABLE emp1 AS (SELECT empno, ename, hiredate, sal
                                    FROM emp);

GENERAL SYSTAX :

CREATE TABLE <table name> AS (SELECT <column list that you wish to include>
                                                     FROM <existing table name>
                                                     [WHERE] <condition> );
where clause is optional.

                                   

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions