How to reorder the table columns (fields)?



How to reorder the table columns (fields)?..

Answer / Neeraj Rastogi

To rearrange columns in a table, you can use the ALTER TABLE statement with the ORDER BY clause in SQL:

```sql
ALTER TABLE table_name
RENAME COLUMN old_column_name TO new_column_name;

ALTER TABLE table_name
MODIFY COLUMN column_name DATA TYPE new_data_type;
```

You can repeat the above steps for each column you want to rearrange, keeping in mind that the first and last columns cannot be modified directly. You may also need to update related views, stored procedures, or triggers after reordering table columns.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Database Management Interview Questions

What are the limitations of rdbms?

1 Answers  


Enlist various types of interactions created by dbms?

1 Answers  


Why do we use databases?

1 Answers  


What SYSTEM VARIABLE is used to refer DATABASE TIME ?

1 Answers  


What is string in database?

1 Answers  


Define primary and unique key?

1 Answers  


Discuss some of the techniques that can be used to tune operational performance.

1 Answers  


what is s/w lifecycle?

5 Answers   IBM,


Explain the different types of languages that are available in the dbms?

1 Answers  


what is "TABLE" datatype ?

2 Answers  


What are codd rules?

1 Answers  


What is data model example?

1 Answers  


Categories