CREATE a table from another table
Answers were Sorted based on User's Feedback
Answer / mohammadali.info
Syntax #1 - Copying all columns from another table
The basic syntax is:
CREATE TABLE new_table
AS (SELECT * FROM old_table);
For example:
CREATE TABLE suppliers
AS (SELECT *
FROM companies
WHERE id > 1000);
Syntax #2 - Copying selected columns from another table
The basic syntax is:
CREATE TABLE new_table
AS (SELECT column_1, column2, ... column_n FROM old_table);
For example:
CREATE TABLE suppliers
AS (SELECT id, address, city, state, zip
FROM companies
WHERE id > 1000);
Syntax #3 - Copying selected columns from multiple tables
The basic syntax is:
CREATE TABLE new_table
AS (SELECT column_1, column2, ... column_n
FROM old_table_1, old_table_2, ... old_table_n);
For example:
CREATE TABLE suppliers
AS (SELECT companies.id, companies.address, categories.cat_type
FROM companies, categories
WHERE companies.id = categories.id
AND companies.id > 1000);
| Is This Answer Correct ? | 4 Yes | 5 No |
How to link tables in sql server?
What is enhanced database mirroring in sql server 2008?
Can sql servers linked to other servers like oracle?
which one will take 1st priority in case of insert statement and select statement???
tell me the disaster recovery plan
What is the difference between clustered index and primary key?
What Is Rdbms?
What is the difference between local and global temporary tables?
What are the different ways you can create databases in sql server?
Are connections to sql server encrypted?
Which data type columns are the best candidates for full-text indexing?
What is the need for indexing?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)