From: Eloi G. <el...@re...> - 2003-08-23 05:11:43
|
CREATE TABLE test ( id int NOT NULL PRIMARY KEY ); This -should- work for all db's. The PEAR routines that phpWS appear to search for the primary index and will automatically set up a _seq table i= f you enable autoincrementing in the core->sqlInsert() parameters. Eloi George ----- Original Message ----- From: "Richard Sumilang" <ri...@ri...> To: <php...@li...> Sent: Wednesday, August 20, 2003 1:37 PM Subject: [Phpwebsite-developers] Auto Increment SQL problem As I looked for what is the common standard for creating auto increment columns in a table I found that there isn't one. I know the built in sequencing PWS has in play for auto increment has some play in this but not completely sure how it works when setting up a table? What do you guys think will be the best way to create tables with an AUTO INCREMENT column with PWS? I currently don't care for too much support for Oracle right now as you can see with the example below. Syntax for MySQL =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D CREATE TABLE test ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY ( id) ); Syntax for PostgreSQL =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D CREATE TABLE test ( id SERIAL , PRIMARY KEY (id) ); Syntax for Oracle9i =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D -- --Create sequence called demo -- CREATE SEQUENCE "DEMO"."SEQ_INSERT" INCREMENT BY 1 START WITH 1780229 MAXVALUE 1.0E28 MINVALUE 1 NOCYCLE CACHE 20 ORDER -- -- Next place a trigger for that column you want to auto increment -- -- CREATE OR REPLACE TRIGGER "DEMO"."TRG_EMP_INSERT" BEFORE INSERT ON "DEMO"."EMP" FOR EACH ROW BEGIN SELECT seq_insert .nextval -- get the new seq number INTO :NEW.emp_no -- :NEW missed FROM DUAL; END; # Found source for Oracle at http://www.experts-exchange.com/Databases/Q_20412293.html Best Regards, - Richard S ------------------------------------------------------- This SF.net email is sponsored by Dice.com. Did you know that Dice has over 25,000 tech jobs available today? From careers in IT to Engineering to Tech Sales, Dice has tech jobs from the best hiring companies. http://www.dice.com/index.epl?rel_code=104 _______________________________________________ Phpwebsite-developers mailing list Php...@li... https://lists.sourceforge.net/lists/listinfo/phpwebsite-developers |