This is a discussion on Adding a new Column in middle of the Table within the Database Support forums, part of the Web Development category; Hi Friends, MYSQL Just want to share the Concept of Adding a New Field in the Middle of the Table ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi Friends, MYSQL Just want to share the Concept of Adding a New Field in the Middle of the Table CREATE TABLE IF NOT EXISTS test ( id INTEGER AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY(id) ); Now i want to add a field between id and name in the table. ALTER TABLE test ADD emp_id INTEGER NOT NULL AFTER id;
__________________ -Murali.. |
| Sponsored Links |
| |||
| Mr.vadivelanvaidyanathan, In Mysql I mean to say that if we have created a table with the defined structure. Now i want to add one more field to that table, if am adding a new field that will be added as the last field in the table. For Ex: I want to store the Employee Id,Name and Designation. My Table Structure is, CREATE TABLE EMP ( EMP_ID INTEGER AUTO_INCREMENT COMMENT'Primary Key', EMP_NAME VARCHAR(100) NOT NULL COMMENT'Employee Name', EMP_DESIGNATION VARCHAR(100) NOT NULL COMMENT'Employee Designation', EMP_ACTIVE INTEGER DEFAULT 1 NOT NULL COMMENT'1- Working Currently,Suspended Temporarly,Left the Office', PRIMARY KEY(EMP_ID) ); Now i want to include the Employee salary with Name and Designation. Then ALTER TABLE EMP ADD EMP_SAL INTEGER NOT NULL; Now the new added field will be added as the last field in the table,i.e EMP_ID EMP_NAME EMP_DESIGNATION EMP_ACTIVE EMP_SAL - New Added Field But i wish to add the field in order,Employee Salary must be next to the Designation Field, Then the Syntax is, ALTER TABLE EMP ADD EMP_SAL INTEGER NOT NULL AFTER EMP_DESIGNATION; Now the Order of the Field will be as follows, EMP_ID EMP_NAME EMP_DESIGNATION EMP_SAL - New Added Field EMP_ACTIVE Its Clear..... ![]()
__________________ -Murali.. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| adding comment box to my website | charcola | PHP Programming | 9 | 12-10-2007 11:35 AM |
| What is the difference between DELETE TABLE and TRUNCATE TABLE commands in SQL Server | oxygen | Database Support | 6 | 11-23-2007 06:17 AM |
| C is a structural or highlevel or middle level language which one is correct answer | vigneshgets | C and C++ Programming | 3 | 08-25-2007 01:55 PM |
| Problem in align a text to middle of the screen in Console Application? | kingmaker | C# Programming | 0 | 07-21-2007 12:40 AM |
| When designing a database table, how do you avoid missing column values for non-prima | Arun | Database Support | 2 | 07-18-2007 10:43 PM |