請教數據庫專家個初級問題,這個用t-sql怎麽寫?

來源: 戲雨飛鷹 2009-04-27 10:38:01 [] [博客] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (379 bytes)
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)?

所有跟帖: 

美國老土,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- 給 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- 給 oops_yz 發送悄悄話 (58 bytes) () 04/27/2009 postreply 11:06:17

好! 謝謝:)。就是想確定一下:沒有辦法可以直接一步到位? -戲雨飛鷹- 給 戲雨飛鷹 發送悄悄話 戲雨飛鷹 的博客首頁 (0 bytes) () 04/27/2009 postreply 11:10:41

wow!!! -HappyNow?!- 給 HappyNow?! 發送悄悄話 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?!- 給 HappyNow?! 發送悄悄話 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- 給 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

請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉/移除任何Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”