Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 31st, 2004, 05:59 AM
Decebal Decebal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 25 Decebal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 45 sec
Reputation Power: 0
add a column at a specific place

I have a table with about 40 columns. I want to add some columns after column 5. There are sql versions where you can do something like:

ALTER TABLE THISTABLE
ADD FIELD5a INTEGER AFTER FIELD5,
ADD FIELD5b INTEGER AFTER FIELD5,
ADD FIELD5c INTEGER AFTER FIELD5,
ADD FIELD5d INTEGER AFTER FIELD5,
ADD FIELD5e INTEGER AFTER FIELD5

Is something like this possible in FireBird?

Reply With Quote
  #2  
Old August 31st, 2004, 10:19 AM
snf173 snf173 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 5 snf173 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 58 m 46 sec
Reputation Power: 0
Quote:
Originally Posted by Decebal
I have a table with about 40 columns. I want to add some columns after column 5. There are sql versions where you can do something like:

ALTER TABLE THISTABLE
ADD FIELD5a INTEGER AFTER FIELD5,
ADD FIELD5b INTEGER AFTER FIELD5,
ADD FIELD5c INTEGER AFTER FIELD5,
ADD FIELD5d INTEGER AFTER FIELD5,
ADD FIELD5e INTEGER AFTER FIELD5

Is something like this possible in FireBird?


Yes it is !
From the top of my head, I think it's something like :
ALTER TABLE <TABLENAME>
ADD <COLUMN> <COLUMNDEF> POSITION X;

Where X is the number where you want to place the field.

Reply With Quote
  #3  
Old August 31st, 2004, 10:56 AM
pabloj's Avatar
pabloj pabloj is online now
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,906 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 7 h 8 m 35 sec
Reputation Power: 279
That's right, check the docs

Reply With Quote
  #4  
Old August 31st, 2004, 03:40 PM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,005 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 11 h 40 m 57 sec
Reputation Power: 67
Quote:
I want to add some columns after column 5.

I'm curious what the reason for this would be. I really cannot image any requirement where the ordering of the column in the table would be of any importance to the client.

I can always retrieve the columns in the order I want to. Using a SELECT * inside a program is a very bad habbit anyway. And besides the relational model neither has a notion of row ordering (apart from ORDER BY) nor of column ordering (apart from the order defined in the SELECT list)

Reply With Quote
  #5  
Old September 1st, 2004, 04:55 AM
Decebal Decebal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 25 Decebal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by snf173
Yes it is !
From the top of my head, I think it's something like :
ALTER TABLE <TABLENAME>
ADD <COLUMN> <COLUMNDEF> POSITION X;

Where X is the number where you want to place the field.


It is:
ALTER TABLE <TABLENAME>
ADD <COLUMN> <COLUMNDEF> ;
ALTER TABLE <TABLENAME>
ALTER COLUMN <COLUMN> POSITION X;

Reply With Quote
  #6  
Old September 1st, 2004, 04:59 AM
Decebal Decebal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 25 Decebal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by shammat
I'm curious what the reason for this would be. I really cannot image any requirement where the ordering of the column in the table would be of any importance to the client.


Because we would like to have fields that are logical related to be by eachother. Is very nice when using something like Database Workbench.

Reply With Quote
  #7  
Old September 1st, 2004, 05:55 AM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,005 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 11 h 40 m 57 sec
Reputation Power: 67
Quote:
Originally Posted by Decebal
Because we would like to have fields that are logical related to be by eachother. Is very nice when using something like Database Workbench.

OK, so it's more an aesthetic issue then a functional one

Cheers
Thomas

Reply With Quote
  #8  
Old September 1st, 2004, 06:31 AM
Decebal Decebal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 25 Decebal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by shammat
OK, so it's more an aesthetic issue then a functional one

Cheers
Thomas


Yes, for me it is.
Also, I am not the only one using the database. So better save then sorry.

Reply With Quote
  #9  
Old September 6th, 2004, 11:20 AM
jayjoh jayjoh is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 4 jayjoh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb

Quote:
Originally Posted by shammat
I'm curious what the reason for this would be. I really cannot image any requirement where the ordering of the column in the table would be of any importance to the client.

I can always retrieve the columns in the order I want to. Using a SELECT * inside a program is a very bad habbit anyway. And besides the relational model neither has a notion of row ordering (apart from ORDER BY) nor of column ordering (apart from the order defined in the SELECT list)


Personally:

1. As a programmer, when looking at table definitions or working with dumps, it's just easier if fields come in some logical sequene, like "name,address,city,state,zip" rather than "city,name,zip,address,state".

2. I've had a few cases where I've written generic code that builds display or edit windows by getting the list of columns from the database and throwing the fields on the screen, using the field name for a label and figuring out what sort of field to use for the data based on the data type. Sure, some input screens require more sophistication that that. But I often have many tables that are simply a set of text fields where something like that works fine. (I'm a big believer in using generic code: if I write it once and use it ten times, sure generic code is tougher and it may take me twelve times as long to write, but then I only have to debug it once instead of ten times, and when the user comes back with a change -- maybe this has never happened to you -- I only have to change it once instead of ten times.)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > add a column at a specific place


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT