Mega Code Archive

 
Categories / MySQL / Table Index
 

Change column type and settings during table copying

mysql> mysql> mysql> mysql> CREATE   TABLE TEAMS     ->         (TEAMNO         INTEGER      NOT NULL,     ->          EmployeeNO       INTEGER      NOT NULL,     ->          DIVISION       CHAR(6)      NOT NULL,     ->          PRIMARY KEY    (TEAMNO)             ); mysql> mysql> mysql> INSERT INTO TEAMS VALUES (1,  6, 'first'); mysql> INSERT INTO TEAMS VALUES (2, 27, 'second'); mysql> mysql> CREATE TABLE TEAMS_COPY5     ->       (TEAMNO     INTEGER NOT NULL PRIMARY KEY,     ->        EmployeeNO   INTEGER NULL,     ->        DIVISION   CHAR(10) NOT NULL) AS     -> (SELECT   *     ->  FROM     TEAMS)     -> ; Query OK, 2 rows affected (0.00 sec) Records: 2  Duplicates: 0  Warnings: 0 mysql> mysql> drop table teams_copy5; Query OK, 0 rows affected (0.00 sec) mysql> mysql> CREATE TABLE TEAMS_COPY5     ->       (EmployeeNO   INTEGER NULL,     ->        DIVISION   CHAR(10) NOT NULL) AS     -> (SELECT   *     ->  FROM     TEAMS); Query OK, 2 rows affected (0.00 sec) Records: 2  Duplicates: 0  Warnings: 0 mysql> mysql> mysql> drop table teams; Query OK, 0 rows affected (0.00 sec) mysql> drop table teams_copy5; Query OK, 0 rows affected (0.00 sec)