Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

CREATE a table from another table

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to implement service broker?

1067


What do you understand by the data quality services in sql server?

979


Why do we need different type of parameter?

1105


What is the difference between Triggers and Stored Procedure?

1149


What action plan is preferred if sql server is not responding?

1149


what is bit datatype and what's the information that can be stored inside a bit column? : Sql server database administration

1041


What is a linked server in sql server?

1126


What are the types of database recovery models?

1184


What are the different types of subquery?

1198


You want to implement the one-to-many relationship while designing tables. How would you do it?

994


What is the difference between sql server 2000 object owner and sql server 2005 schema? : sql server database administration

1035


What are the kinds of subquery?

1068


What are the 2 types of classifications of constraints in the sql server?

1176


Can a table be created inside a trigger?

1010


What is the syntax for encrypting a column in SQL Server?

1169