SQL statement to create a new table from an old table in SQL

Source: Internet
Author: User

Today, on the Internet, according to the old table to create a new table SQL statement, the Web gave two answers

CREATE table tab_new like Tab_old (creating a new table with the old table )

CREATE TABLE tab_new as Select Col1,col2 ... From tab_old definition only

Two statements have been tried, error.

The correct method is select * into newtable from oldtable; If you do not want to lead the record, just want to make table structure: SELECT * into NewTable from oldtable where 1=2;

If newtable already exists, you want to import the record: INSERT INTO newtable select * from Oldtable where ...

Some of them also draw on some other friends, I summarize in this!!

SQL statement to create a new table from an old table in SQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.