Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Create a New Table by Selecting Rows from Another Table
How To Create a New Table by Selecting Rows from Another Table? - MySQL FAQs - Understanding SQL CREATE, ALTER and DROP Statements
✍: FYIcenter.com
Let's say you have a table with many data rows, now you want to create a backup copy of this table of all rows or a subset of them, you can use the "CREATE TABLE ... SELECT" statement. The tutorial script below gives you a good example:
mysql> INSERT INTO tip VALUES (1, 'Learn MySQL', 'Visit dev.fyicenter.com','2006-07-01'); Query OK, 1 row affected (0.62 sec) mysql> CREATE TABLE tipBackup SELECT * FROM tip; Query OK, 1 row affected (0.49 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> SELECT * FROM tipBackup; +----+-------------+-------------------------+-------------+ | id | subject | description | create_date | +----+-------------+-------------------------+-------------+ | 1 | Learn MySQL | Visit dev.fyicenter.com | 2006-07-01 | +----+-------------+-------------------------+-------------+ 1 row in set (0.00 sec)
As you can see, this SQL script created a table called "tipBackup" using the same column definitions as the "tip" table and copied all data rows into "tipBackup".
2007-05-11, 4726👍, 0💬
Popular Posts:
How do I install JUnit? First I will download the lastest version of JUnit. Then I will extract all ...
How To Get the Minimum or Maximum Value of an Array? - PHP Script Tips - PHP Built-in Functions for ...
If client side validation is enabled in your Web page, does that mean server side code is not run? W...
What are the two kinds of comments in JSP and what's the difference between them? <%-- JSP Co...
Jack developed a program by using a Map container to hold key/value pairs. He wanted to make a chang...