fatkatie Posted February 23, 2017 Share Posted February 23, 2017 I want to alter a table and add a new column. I want to add a second email address column and I want the design of this new column to match with the first. For example, if email varchar(128) default null then I want the new column the "same" as in: email2 varchar(128) default null Can column design values be copied in this way within the sql construct? Can column design values be collected from another separate table? Quote Link to comment https://forums.phpfreaks.com/topic/303281-alter-table-add-column-like-this-other-column-over-here/ Share on other sites More sharing options...
Solution Barand Posted February 23, 2017 Solution Share Posted February 23, 2017 (edited) You can create a table which has exactly the same structure as another CREATE TABLE table2 LIKE table1; I know of nothing similar down at the ADD COLUMN level. Edited February 23, 2017 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/303281-alter-table-add-column-like-this-other-column-over-here/#findComment-1543295 Share on other sites More sharing options...
Jacques1 Posted February 23, 2017 Share Posted February 23, 2017 Can column design values be copied in this way within the sql construct? Why would you want that? Duplicating columns is a bad sign and sounds like the usual MySQL-is-Excel confusion. Quote Link to comment https://forums.phpfreaks.com/topic/303281-alter-table-add-column-like-this-other-column-over-here/#findComment-1543299 Share on other sites More sharing options...
fatkatie Posted February 24, 2017 Author Share Posted February 24, 2017 Thank you for your comment. Quote Link to comment https://forums.phpfreaks.com/topic/303281-alter-table-add-column-like-this-other-column-over-here/#findComment-1543321 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.