add new field between existing fields?? [message #7345] |
Thu, 05 June 2003 13:01 |
Marx
Messages: 4 Registered: April 2002
|
Junior Member |
|
|
I know how to add a new field but my trouble is, how would I put in between 2 other existing fields. Currently my shipping table is
table: shipping
fields
SHIPID, NOT NULL, NUMBER(5)
INVID, NOT NULL, NUMBER(5)
DATE_EXPECTED, NOT NULL, DATE
DATE_RECIEVED, DATE
QUANTITY_RECIEVED, NUMBER(5)
I want to add a field called quantity_expected and place it in between date_expected and date_recieved. So far I'm stuck the following
ALTER TABLE shipping
ADD (quantity_expected NUMBER(5) CONSTRAINT shipping_quantity_expected_nn NOT NULL);
|
|
|
Re: add new field between existing fields?? [message #7347 is a reply to message #7345] |
Thu, 05 June 2003 13:47 |
|
Barbara Boehmer
Messages: 9090 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
The only time that the order of fields will matter is if you want the convenience of just doing select * and having them displayed in the desired order. The following will accomplish the task, but if there are any other constraints, you will have to drop and re-create them.
CREATE TABLE shipping2
(SHIPID NUMBER (5) NOT NULL,
INVID NUMBER (5) NOT NULL,
DATE_EXPECTED DATE NOT NULL,
quantity_expected NUMBER (5) NOT NULL,
DATE_RECIEVED DATE,
QUANTITY_RECIEVED NUMBER (5))
/
INSERT INTO shipping2
SELECT SHIPID, INVID, DATE_EXPECTED, 0, DATE_RECIEVED, QUANTITY_RECIEVED
FROM shipping
/
DROP TABLE shipping
/
CREATE TABLE shipping AS SELECT * FROM shipping2
/
DROP TABLE shipping2
/
|
|
|
|