if I create a table as below:
CREATE TABLE table1(
column1 varchar(50),
column2 varchar(50),
column3 varchar(50),
column4 varchar(50));
what is the code for adding the column named “columnX” after column2 to the table shown above?
ALTER TABLE table1 ADD columnX varchar(50)
可以add a new column,但怎麽加到指定位置呢(after column2)?
請教數據庫專家個初級問題,這個用t-sql怎麽寫?
所有跟帖:
• 美國老土,it's a piece of cake for you, thanks! -戲雨飛鷹- ♀ (0 bytes) () 04/27/2009 postreply 10:45:17
• no can't do, have to drop and recreate -forweb- ♂ (0 bytes) () 04/27/2009 postreply 10:52:41
• Thanks. This is just what I thought. but -戲雨飛鷹- ♀ (75 bytes) () 04/27/2009 postreply 10:59:59
• Select * into table2 from table1 -oops_yz- ♀ (58 bytes) () 04/27/2009 postreply 11:06:17
• 好! 謝謝:)。就是想確定一下:沒有辦法可以直接一步到位? -戲雨飛鷹- ♀ (0 bytes) () 04/27/2009 postreply 11:10:41
• wow!!! -HappyNow?!- ♂ (970 bytes) () 04/27/2009 postreply 11:35:05
• wow!!! fancy to see you again, HappyNow?!! . how r u doing, bud -戲雨飛鷹- ♀ (67 bytes) () 04/27/2009 postreply 11:49:01
• In MySQL, you can easily do it. -竹杉林- ♂ (64 bytes) () 04/27/2009 postreply 12:28:25
• oh, I love it. But t-sql doesn't support the key "after" ..:) -戲雨飛鷹- ♀ (0 bytes) () 04/27/2009 postreply 12:38:32
• then I don't know. -竹杉林- ♂ (0 bytes) () 04/27/2009 postreply 12:51:33
• Don't you hint t-sql supports the key "before"? haha. -竹杉林- ♂ (0 bytes) () 04/27/2009 postreply 12:52:42
• 為什麽要非要插入到這個位置呢? -小丹尼- ♂ (108 bytes) () 04/27/2009 postreply 13:25:20
• agreed; but "look/feel" good to the designer -:))) -HappyNow?!- ♂ (0 bytes) () 04/27/2009 postreply 13:30:59
• 我覺得這沒有必要,本來數據和表現就應該分開 -小丹尼- ♂ (77 bytes) () 04/27/2009 postreply 13:34:27
• when you use "select * from", -竹杉林- ♂ (28 bytes) () 04/27/2009 postreply 13:32:45
• 個人以為,select *不是一個好的SQL習慣 -小丹尼- ♂ (32 bytes) () 04/27/2009 postreply 13:43:23
• 有道理。謝謝。在學這個,是書上的一道題目:) -戲雨飛鷹- ♀ (0 bytes) () 04/27/2009 postreply 13:54:57
• 幫你查了一下 -安心草- ♀ (110 bytes) () 04/27/2009 postreply 14:06:30
• xiexiexiexie, my smarty:) -戲雨飛鷹- ♀ (0 bytes) () 04/27/2009 postreply 14:15:12
• In SQL management studio -ExpectingMM- ♀ (159 bytes) () 04/27/2009 postreply 18:40:41
• Thanks, ExpectingMM. very busy? -戲雨飛鷹- ♀ (0 bytes) () 04/27/2009 postreply 20:25:56
• agree,基本上schama的改變不太用t-sql來做 -撅著挺好- ♂ (89 bytes) () 04/28/2009 postreply 04:43:48
• :) thanks. -戲雨飛鷹- ♀ (0 bytes) () 04/28/2009 postreply 14:00:05