Bug #13495 | CREATE TABLE ... SELECT reverses the order of columns | ||
---|---|---|---|
Submitted: | 26 Sep 2005 18:38 | Modified: | 26 Sep 2005 19:01 |
Reporter: | Dave Pullin (Basic Quality Contributor) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.0.12-beta-nt-log | OS: | Windows (Windows 2000) |
Assigned to: | MySQL Verification Team | CPU Architecture: | Any |
[26 Sep 2005 18:38]
Dave Pullin
[26 Sep 2005 19:01]
MySQL Verification Team
Please read the Manual at: http://dev.mysql.com/doc/mysql/en/create-table.html This creates a MyISAM table with three columns, a, b, and c. Notice that the columns from the SELECT statement are appended to the right side of the table, not overlapped onto it.
[26 Sep 2005 19:45]
Dave Pullin
Thanks, The SELECT columns may be appended to right but there are no generated columns in the example I gave; All of the columns are explicitly created in the create table(). I think I understand how you got here (because explicit column specification is newer than the simple create table x select ...) but you have end with an odd definition: create table x (col_specs) select cols .... The TYPE of the columns in taken from col_specs but the order is taken from 'cols', except if the col_spec isn't in 'cols'. I guess the documentation could be improved in this area.
[30 Sep 2005 19:44]
Paul DuBois
I've added this to the manual: In a table resulting from CREATE TABLE ... SELECT, columns named only in the CREATE TABLE part come first. Columns named in both parts or only in the SELECT part come after that. The data type of SELECT columns can be overridden by also specifying the column in the CREATE TABLE part.
[30 Sep 2005 20:12]
Dave Pullin
Great. Thanks.