I have knowledge on sql server but now i worked on MySQL because of my company requirements. Is it possible to add a column before a specified column.
Actually i tried this logic
alter table marks add telugu int after typeofexam;
it works.when I'm trying to do the below logic
alter table marks add telugu int before typeofexam;
where marks is a table name, telugu a column name and typeofexam is a column name, it shows syntax errors.
Will you help me to get the logic.
The syntax to add a column in a table in MySQL (using the ALTER TABLE statement) is: ALTER TABLE table_name ADD new_column_name column_definition [ FIRST | AFTER column_name ]; table_name.
Using SQL Server Management StudioIn Object Explorer, right-click the table with columns you want to reorder and select Design. Select the box to the left of the column name that you want to reorder. Drag the column to another location within the table.
Use the FIRST
keyword:
alter table marks add telugu int FIRST;
Documentation: http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
The order isn't a big deal anyway; it's more of a human thing than a requirement. Most front ends will allow you to re order easily though.
Actually ordering of column does not matter in a database, you can always create a view which will display in the ordering of column you want.
Here is a nice blog which talks about them for SQL Server but the same is valid for MySQL as well. http://blog.sqlauthority.com/2008/04/08/sql-server-change-order-of-column-in-database-tables/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With