Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL SELECT INTO Equivalent?

Tags:

sql

mysql

In SQL Server, I can copy tables or temporary tables to new table, using a SELECT* INTO.. syntax.

Someone know how can I make this same action in MySQL?

like image 399
Renato Bezerra Avatar asked Oct 09 '09 23:10

Renato Bezerra


People also ask

Does MySQL support SELECT into?

MySQL Server doesn't support the SELECT ... INTO TABLE Sybase SQL extension. Instead, MySQL Server supports the INSERT INTO ... SELECT standard SQL syntax, which is basically the same thing.

What is into Outfile in MySQL?

INTO OUTFILE is the complement of LOAD DATA . Column values are written converted to the character set specified in the CHARACTER SET clause. If no such clause is present, values are dumped using the binary character set. In effect, there is no character set conversion.

What is the difference between SELECT into and insert into?

INSERT INTO SELECT vs SELECT INTO: Both the statements could be used to copy data from one table to another. But INSERT INTO SELECT could be used only if the target table exists whereas SELECT INTO statement could be used even if the target table doesn't exist as it creates the target table if it doesn't exist.

What is SELECT * from in MySQL?

The SELECT statement is used to select data from a database. The data returned is stored in a result table, called the result-set.


1 Answers

See CREATE TABLE ... AS SELECT .... Note that this will not recreate indexes and foreign keys, as was already noted.

like image 157
Dark Falcon Avatar answered Nov 15 '22 15:11

Dark Falcon