web analytics

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

Options

codeling 1599 - 6654
@2016-02-04 11:07:42

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);

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com