Forums

PHP

This topic is locked

postgresql->mysql conversion help

Posted 11 Mar 2003 00:42:19
1
has voted
11 Mar 2003 00:42:19 James Pratt posted:
Hi,

I am trying to get the phakt tutorial working on my system. I am attempting to use the postgresql based example that I downloaded from this site. Unfortuntely I have only got access to a MySql server. So I have tried to convert the script to set up the database to something that will work on a Mysql database. I have changed the code :
<font color=green>
/* --------------------------------------------------------
Sequences
-------------------------------------------------------- */
CREATE SEQUENCE "contacts_con_id_con_seq" start 1 increment 1 maxvalue 9223372036854775807 minvalue 1 cache 1;
CREATE SEQUENCE "users_usr_id_usr_seq" start 1 increment 1 maxvalue 9223372036854775807 minvalue 1 cache 1;

/* --------------------------------------------------------
Table structure for table "users_usr"
-------------------------------------------------------- */
CREATE TABLE "users_usr" (
"id_usr" int4 DEFAULT nextval('"users_usr_id_usr_seq"'::text) NOT NULL,
"username_usr" varchar(8) NOT NULL,
"password_usr" varchar(8) NOT NULL,
"level_usr" int2 NOT NULL default 0,
CONSTRAINT "users_usr_pkey" PRIMARY KEY ("id_usr"
);

/* --------------------------------------------------------
Table structure for table "contacts_con"
-------------------------------------------------------- */
CREATE TABLE "contacts_con" (
"id_con" int4 DEFAULT nextval('"contacts_con_id_con_seq"'::text) NOT NULL,
"idusr_con" int4 NOT NULL references users_usr(id_usr) on delete cascade,
"firstname_con" varchar(100) NOT NULL,
"lastname_con" varchar(100) NOT NULL,
"email_con" varchar(100) NOT NULL,
"birthdate_con" date,
CONSTRAINT "contacts_con_pkey" PRIMARY KEY ("id_con"
);
CREATE INDEX "contacts_con_idusr_con_key" ON "contacts_con" ("idusr_con";
</font id=green>
to :
<font color=red>
/* --------------------------------------------------------
Table structure for table "users_usr"
-------------------------------------------------------- */
CREATE TABLE "users_usr" (
"id_usr" int NOT NULL auto_increment,
"username_usr" varchar(8) NOT NULL,
"password_usr" varchar(8) NOT NULL,
"level_usr" tinyint NOT NULL default 0,
PRIMARY KEY ("id_usr",
UNIQUE KEY "id_usr" ("id_usr"
);

/* --------------------------------------------------------
Table structure for table "contacts_con"
-------------------------------------------------------- */
CREATE TABLE "contacts_con" (
"id_con" int NOT NULL auto_increment,
"idusr_con" int NOT NULL references users_usr(id_usr) on delete cascade,
"firstname_con" varchar(100) NOT NULL,
"lastname_con" varchar(100) NOT NULL,
"email_con" varchar(100) NOT NULL,
"birthdate_con" date,
PRIMARY KEY ("id_con",
UNIQUE KEY "id_con" ("id_con"
);
</font id=red>
I can't pretend to really know what I am doing here. This code doesn't create any tables at all though!

Can some kind soul tell me what I am doing wrong??

James Pratt.


Replies

Replied 12 Mar 2003 14:09:50
12 Mar 2003 14:09:50 Tim Green replied:
James,

You've been posting this exact same post to various lists. I'm sorry that you haven't received any help from them, but you didn't get the PostGres example from here.

It'll probably help you to know that PostGres to MySQL Conversion is not a simple task, as PostGres and MySQL are completely different beasts.

For example, SEQUENCES aren't supported at all under MySQL, so there is no way that the code that you have posted will work. A little research (ie: looking it up in the MySQL manual) would have revealed this much. Neither is CONSTRAINT a valid MySQL keyword...

I'm sorry but posting SQL like this and asking for a conversion, when you didn't even get the code from this site isn't really fair, and so I'm locking this thread.



Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Reply to this topic