Differences to other RDMSes

Oracle, PostgreSQL, and SQL Server all offer the same way of creating a new table and inserting data into it from an existing table; however, they MySQL differs from all of these. 

In Oracle, PostgreSQL, and SQL Server, if you want to create a new table and insert data into it, you use the SELECT...INTO statement, rather than CREATE TABLE, then use the SELECT statement, as in MySQL. You can execute the following query to create a new table from an existing table via a SELECT statement:

SELECT * 
INTO managerscopy
FROM managers;

You can also specify column names instead of selecting them all, as in the following query:

SELECT playerID, yearID, teamID, G 
INTO managerscopy
FROM managers;

The previous query creates a new table with just the four columns from the existing table specified. You can also use a WHERE clause to limit the rows. 

Additionally, you can just create the schema of the table by executing the following query:

SELECT * INTO managerscopy
FROM managers
WHERE 1 = 0;

In the previous query, WHERE 1=0 will never be true, so the query only creates the table but doesn't populate it with data. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.75.133