MySQL Forums
Forum List  »  PostgreSQL

Re: Postgresql to mysql
Posted by: mona hazarika
Date: September 18, 2008 03:42AM

Hi everyone,

I am converting a postgres sql file into a mysql sql file.I have some create table queries as well as sequences for most of the tables.I know that we have to assign auto_increment to some column if a sequence is created for that column.But wat if a sequence is being created for the whole table ?Wat wil be the equivalent for the sequnce part in mysql?

I have a create table syntax as follws:

CREATE TABLE calendar_events (
id numeric NOT NULL,
syear numeric(4,0),
school_id numeric,
school_date date,
title character varying(50),
description character varying(500)
);

CREATE SEQUENCE calendar_events_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;

SELECT pg_catalog.setval('calendar_events_seq', 25, true);

ALTER TABLE ONLY calendar_events
ADD CONSTRAINT calendar_events_pkey PRIMARY KEY (id);


Now i have converted the create table query into mysql syntax but i dont know wat to do with the sequence part for the whole table.Should i assume that the sequence defined is for the "id" in the table calendar_events and so assign auto_increment for that field?

Will this equivalent for the above table be correct?

CREATE TABLE IF NOT EXISTS `calendar_events` (
`id` double NOT NULL auto_increment,
`syear` double default '0',
`school_id` double default '0',
`school_date` date default NULL,
`title` varchar(50) default '',
`description` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Options: ReplyQuote


Subject
Views
Written By
Posted
12212
July 16, 2004 12:28PM
9870
August 02, 2004 07:44PM
9080
February 03, 2008 05:32PM
Re: Postgresql to mysql
9540
September 18, 2008 03:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.