web analytics
How to create a new table with the same structure of a specified table? Options
codeling
Posted: Thursday, February 4, 2016 11:07:42 AM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 944
Points: 3969

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);
Sponsor
Posted: Thursday, February 4, 2016 11:07:42 AM
 
Users browsing this topic
Guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


© 2018 Digcode.com. All rights reserved.