How to create a new table with the same structure of a specified table? Options

codeling Posts: 1057 Points: 4443
Posted: Thursday, February 4, 2016 11:07:42 AM

Suppose you have a table named employee with the following columns:

  • employee_id
  • last_name
  • job_id
  • commission_pct
  • department_id

And you want to create new table named contract_workers with the same columns as employee table, the fastest way to chieve this is to run the following DDL statement:

CREATE TABLE contract_workers AS (SELECT * FROM employees where 1=2);
Users browsing this topic