Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > Other Topics > Programming

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 05-24-2012, 05:43 PM   #16
veteran
 
MrWooster's Avatar
 
Join Date: Mar 2007
Location: Shoving AK
Posts: 2,839
Re: SQL: Create primary key for existing table

Ah, sorry I misunderstood you question.

When we deploy our software, one of the steps for the client is to run an SQL file which performs all the DB modifications. Its done this way as we dont have direct access to their database and it means we can just ship them an SQL file which run on their own servers.

There is no reason not to use a GUI tool if one is available, but I think its also good to understand the underlying SQL. Its very easy to press a button in a GUI without actually realising what its doing.
MrWooster is offline   Reply With Quote
Old 05-24-2012, 05:57 PM   #17
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK
Posts: 9,155
Re: SQL: Create primary key for existing table

Some people, the sort who know the commands already - can probably type "alter table myRecords add column id int auto_increment first, add primary key(id);" before the splash screen for Enterprise Manager has disappeared.
_dave_ is offline   Reply With Quote
Old 05-24-2012, 05:58 PM   #18
Carpal \'Tunnel
 
Gullanian's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 13,022
Re: SQL: Create primary key for existing table

Ah ok, for upgrade scripts that kind of makes sense. I get the feeling a lot of these types of questions are from learners though, I don't think it's something people actually need to learn until they do - their time would be better spent on other parts of SQL.
Gullanian is offline   Reply With Quote
Old 05-24-2012, 05:59 PM   #19
Carpal \'Tunnel
 
Gullanian's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 13,022
Re: SQL: Create primary key for existing table

Quote:
Originally Posted by _dave_ View Post
Some people, the sort who know the commands already - can probably type "alter table myRecords add column id int auto_increment first, add primary key(id);" before the splash screen for Enterprise Manager has disappeared.
Gullanian is offline   Reply With Quote
Old 05-25-2012, 12:18 AM   #20
ɹǝʍoʇpunoɹ
 
RoundTower's Avatar
 
Join Date: Feb 2005
Location: soah made my profile
Posts: 13,927
Re: SQL: Create primary key for existing table

Also, you can tell someone how to do it without having to have the same version of the same database manager GUI. Likewise, if you are googling to solve your own problem you have a much better chance of finding a solution that will work on your setup.
RoundTower is offline   Reply With Quote
Old 05-27-2012, 09:04 AM   #21
grinder
 
shakedown's Avatar
 
Join Date: Aug 2007
Posts: 479
On larger tables an alter table, alter/add column command probably wouldn't be the best way to modify the table as it might cause page splits and data fragmentation (affecting performance).

When you use the GUI the SQL Server IDEs do an ok job at mitigating this behind the scenes - they'll create a new table with the new schema, transfer the data from the old table, then rename the tables.
shakedown is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -4. The time now is 09:10 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.
Copyright © 2008-2010, Two Plus Two Interactive