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 |
What are logical database components? : SQL Server Architecture
Write a SQL query in order to merge two different columns into single column?
What are the triggers in sql?
why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it? : Sql server administration
What are commonly used odbc functions in php?
How get current date in SQL server 2000
4 Answers Cap Gemini, Polaris,
What is a field in a table?
I have Two table First have UserName and second is address, in address table more than value relegated to UserName table, i want to fetch 2nd address if exist other wise 1st address access
Can we store videos inside the sql server table?
Which are the important points to note when multilanguage data is stored in a table?
Can you index views?
What are the advantages of passing name-value pairs as parameters?
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)