I have Table A with 5 columns:
TableA
--
Name
Tel
Address
I want to add a new column (mobile) in between Tel & Email:
TableA
--
Name
Tel
Mobile
Address
If I use
ALTER TABLE TableA
ADD COLUMN Mobile INT NOT NULL
the mobile column is added to the end of the table.
Is there a way to achieve this without dropping the table and moving data to a new table?
解决方案The table is a set of sets in relational model. As there is no explicit order between the rows, there is no explicit order between the columns either. But you can reorder them during projection by specifying the columns you need instead of using *.
But of course the RDBMS, SQL server in your case is still using some ordering. You can't really add the