| Author |
Topic |
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-01-25 : 02:49:01
|
| Hi,I have one table with two cols, i.e. SrNo, Namenoew i wants to add one more column to this table. It should be:SrNo, RollNo, Name. It is possible from table designing. how it can be achieve through DDL.thanks in advance,Mahesh |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-25 : 02:51:13
|
| ALTER TABLE <YourColumnNameHere> ADD RollNo INTMore information exists in Books Online, if you have forgotten about the excellent help file.Peter LarssonHelsingborg, Sweden |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-25 : 02:51:14
|
Why is the ordering of the column a concern to you ?you can always specify the order using select statementselect SrNo, RolNo, Name from table instead of justselect * from table KH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-25 : 02:52:34
|
anyway, it is bad idea to use select *. You will have problem when you add new column to the table KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-25 : 02:56:18
|
Even if you are allowed to do this,select * From tblsalesupdate information_schema.columnsset ordinal_position = 13 - ordinal_position where ordinal_position in (6, 7) and table_name = 'tblsales'select * From tblsales the change is not reflected.Peter LarssonHelsingborg, Sweden |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-25 : 03:01:39
|
if you really want to do this, use Enterprise Manager (EM), table design to do it.But EM will basically create a new table with the column ordering that you want, copy the data over to the new table, drop the old table and rename new table to old table. The foreign key constraints will also be drop and re-created. KH |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2007-01-25 : 04:00:36
|
quote: Originally posted by Peso Even if you are allowed to do this,select * From tblsalesupdate information_schema.columnsset ordinal_position = 13 - ordinal_position where ordinal_position in (6, 7) and table_name = 'tblsales'select * From tblsales the change is not reflected.Peter LarssonHelsingborg, Sweden
Is it safe to play around with the Systems tables, since i had face this problem many times but then i just recreated the table with the specific ordinal position.. and then migrated the data to itChiraghttp://chirikworld.blogspot.com/ |
 |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-01-25 : 04:09:09
|
| thanks all,i wanted to know, is it possible to add column inbetween table through DDL.regards,Mahesh |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2007-01-25 : 04:28:48
|
| No its not possible.. since when ever you add the column using Alter Statment then its added at the end of the table..The other way is the add via EM and then generate the script .. but the script is quite lengthy enough.. since its creates the temp table and then dump the records of the existing table into it and then drop the existings table and then rename the temp table... Chiraghttp://chirikworld.blogspot.com/ |
 |
|
|
rizwan
Starting Member
9 Posts |
Posted - 2007-02-06 : 10:52:53
|
| chiragkhabaria, you said"The other way is the add via EM and then generate the script .. but the script is quite lengthy enough.. since its creates the temp table and then dump the records of the existing table into it and then drop the existings table and then rename the temp table..."Can you please tell how can we generate script after adding column through EM ?Thanks--Rizwww.PDFonFLY.com - Online HTML to PDF conversion |
 |
|
|
|