From: Richard S. <ri...@ri...> - 2003-08-24 06:12:32
|
Great! Works for me +1 for removing database specific auto increment columns and having=20 columns that are integer's and primary keys as the auto increment=20 column. PS, lets not forget to indexes on a separate command. I don't know if=20 there is a sql standard for creating indexes during creation of tables=20= so I can possible be wrong. Tried google but no luck... - Richard S. On Wednesday, August 20, 2003, at 02:03 PM, Eloi George wrote: > CREATE TABLE test ( > id int NOT NULL PRIMARY KEY > ); > > This -should- work for all db's. The PEAR routines that phpWS appear=20= > to > search for the primary index and will automatically set up a _seq=20 > table if > 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 > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single = machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines > at the same time. Free trial click=20 > here:http://www.vmware.com/wl/offer/358/0 > _______________________________________________ > Phpwebsite-developers mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpwebsite-developers > > |