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, 4815👍, 0💬
Popular Posts:
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]? a[i] == *...
How Are Vertical Margins between Two Block Elements Collapsed? - CSS Tutorials - Understanding Multi...
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, ...
Give me the example of SRS and FRS SRS :- Software Requirement Specification BRS :- Basic Requiremen...
How To Control Table Widths? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells Usually, b...