By 25/02/2016 10 Comments

What Is SELECT INTO Statement In SQL?

  • SQL SELECT INTO statement is used to copies/selects rows/records from one table and insert into another table.
  • SQL SELECT INTO statement also copies rows/records into another database table by using IN clause.
  • MySQL does not support SELECT INTO statement.
  • By using SELECT INTO statement you can also copy data from multiple tables into new table.

Syntax-1:

SELECT *
INTO new_table [IN externaldb]
FROM table1;

Syntax-2:

SELECT column_name(s)
INTO new_table [IN externaldb]
FROM table1;

Example-1: copy all columns from city table into city_backup table.

SELECT *
INTO city_backup
FROM city;

Example-2: copy only city_name column from city table into city_backup table.

SELECT city_name
INTO city_backup
FROM city;

Example-3: copy only specific city from city table into city_backup table.

SELECT *
INTO city_backup
FROM city
where city_name = 'karachi';

Note:

  • Above all examples will work in SQL server DBMS.
  • When SELECT INTO statement is used it creates city_backup table automatically in same database (according above examples).






Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .