<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Code Spatter - Latest Comments in Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.disqus.com/</link><description></description><language>en</language><lastBuildDate>Tue, 30 Sep 2008 11:05:35 -0000</lastBuildDate><item><title>Re: Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.com/2008/07/02/tips-for-mysql-to-postgresql-switch/#comment-2751151</link><description>If that query isn't working, try moving the +1 out of the select statement like this:&lt;br&gt;&lt;br&gt;ALTER SEQUENCE univers_id_seq RESTART WITH (SELECT max(id) FROM univers)+1;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">gallard</dc:creator><pubDate>Tue, 30 Sep 2008 11:05:35 -0000</pubDate></item><item><title>Re: Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.com/2008/07/02/tips-for-mysql-to-postgresql-switch/#comment-2668043</link><description>Hello,&lt;br&gt;do you know how to do something like this ?&lt;br&gt;&lt;br&gt;ALTER SEQUENCE univers_id_seq RESTART WITH (SELECT max(id) + 1 FROM univers);&lt;br&gt;&lt;br&gt;Thanks&lt;br&gt;Emilien</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Emilien</dc:creator><pubDate>Sun, 28 Sep 2008 05:26:35 -0000</pubDate></item><item><title>Re: Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.com/2008/07/02/tips-for-mysql-to-postgresql-switch/#comment-1720558</link><description>I noticed another case I may have missed, so I edited the post to catch when the key may be a smallint.&lt;br&gt;&lt;br&gt;Try running these 4 queries. &lt;br&gt;&lt;br&gt;&lt;br&gt;CREATE TABLE manila_area_tbl&lt;br&gt;(&lt;br&gt;area_no SERIAL,&lt;br&gt;area_name varchar(65) NOT NULL,&lt;br&gt;disp_flag char(1) NOT NULL default 1,&lt;br&gt;disp_no smallint NOT NULL,&lt;br&gt;del_flag char(1) NOT NULL default 0,&lt;br&gt;PRIMARY KEY (area_no)&lt;br&gt;)   ;&lt;br&gt;&lt;br&gt;CREATE INDEX disp_no ON manila_area_tbl (disp_no);&lt;br&gt;&lt;br&gt;CREATE INDEX del_flag ON manila_area_tbl (del_flag);&lt;br&gt;&lt;br&gt;ALTER SEQUENCE manila_area_tbl_area_no_seq RESTART WITH 25;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Greg Allard</dc:creator><pubDate>Fri, 11 Jul 2008 09:56:23 -0000</pubDate></item><item><title>Re: Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.com/2008/07/02/tips-for-mysql-to-postgresql-switch/#comment-1720556</link><description>can you give me the sql equivalent of this to postgresql, i'll be using phppgadmin thanks...&lt;br&gt;&lt;br&gt;CREATE TABLE manila_area_tbl&lt;br&gt;(&lt;br&gt;	area_no tinyint(4) NOT NULL auto_increment,&lt;br&gt;	area_name varchar(65) NOT NULL,&lt;br&gt;	disp_flag char(1) NOT NULL default '1',&lt;br&gt;	disp_no tinyint(4) NOT NULL,&lt;br&gt;	del_flag char(1) NOT NULL default '0',&lt;br&gt;	PRIMARY KEY  (`area_no`),&lt;br&gt;	KEY disp_no` (`disp_no`),KEY `del_flag` (`del_flag`)&lt;br&gt;) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=25;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">gilbert</dc:creator><pubDate>Fri, 11 Jul 2008 01:25:07 -0000</pubDate></item><item><title>Re: Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.com/2008/07/02/tips-for-mysql-to-postgresql-switch/#comment-1720555</link><description>I removed the requirement for e-mail. I had no idea WordPress handled it so poorly since I was always logged in.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Greg Allard</dc:creator><pubDate>Wed, 02 Jul 2008 14:18:28 -0000</pubDate></item><item><title>Re: Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.com/2008/07/02/tips-for-mysql-to-postgresql-switch/#comment-1720552</link><description>- datetime in MySQL is equal to timestamp in PostgreSQL. There is no equivalent of MySQL's timestamp data type in PostgreSQL&lt;br&gt;&lt;br&gt;- An enum column in MySQL is equal to a varchar with a check constraint in PostgreSQL, for example:&lt;br&gt;column_name enum('foo', 'bar') is equal to column_name varchar(3) check (column_name IN ('foo', 'bar'))&lt;br&gt;&lt;br&gt;- The blob datatype in MySQL is equal to a bytea datatype in PostgreSQL&lt;br&gt;&lt;br&gt;Also, when truncating a table, I do not believe PostgreSQL resets the sequence for serial columns, so it will need to be done manually.&lt;br&gt;&lt;br&gt;Obviously there are more differences when moving to PostgreSQL, but these are most of the big ones for CREATE TABLE statements.&lt;br&gt;&lt;br&gt;Just a little FYI. I wrote these all out, but forgot my email. Your blog is very unfriendly to comments without an email, as in I lost my comments.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Will</dc:creator><pubDate>Wed, 02 Jul 2008 12:34:07 -0000</pubDate></item><item><title>Re: Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.com/2008/07/02/tips-for-mysql-to-postgresql-switch/#comment-1720553</link><description>@kL&lt;br&gt;Thanks for the comment. I updated the post to cross out the NOT NULL part, I think I meant that only for the auto_increment part, but messed it up.&lt;br&gt;&lt;br&gt;I'll check out the newer versions to see what's been changed. I was on 7.4.7.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Greg Allard</dc:creator><pubDate>Wed, 02 Jul 2008 11:17:18 -0000</pubDate></item><item><title>Re: Tips for MySQL to PostgreSQL Switch</title><link>http://codespatter.com/2008/07/02/tips-for-mysql-to-postgresql-switch/#comment-1720551</link><description>"Remove all instances of NOT NULL"&lt;br&gt;WTF!? This can seriously break many schemas. Don't do this.&lt;br&gt;&lt;br&gt;Postres supports multiple-row inserts only in latest versions (8.3+ IIRC).&lt;br&gt;&lt;br&gt;another useful replacement may be CURRENT_TIMESTAMP with NOW() and timestamp with timestamp without time zone, etc.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">kL</dc:creator><pubDate>Wed, 02 Jul 2008 11:00:39 -0000</pubDate></item></channel></rss>