Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MYSQL to POSTGRESQL Translation

Posted on 2007-11-30
3
Medium Priority
?
2,495 Views
Last Modified: 2008-02-01
Would this translation be correct
Mysql syntax
CREATE TABLE `voicemessages` (
  `id` int(11) NOT NULL auto_increment,
  `msgnum` int(11) NOT NULL default '0',
  `dir` varchar(80) default '',
  `context` varchar(80) default '',
  `macrocontext` varchar(80) default '',
  `callerid` varchar(40) default '',
  `origtime` varchar(40) default '',
  `duration` varchar(20) default '',
  `mailboxuser` varchar(80) default '',
  `mailboxcontext` varchar(80) default '',
  `recording` longblob,
  PRIMARY KEY  (`id`),
  KEY `dir` (`dir`)
) ENGINE=MyISAM;

To this postgresql syntax

CREATE TABLE voicemessages (
id      integer CONSTRAINT no_null NOT NULL CONSTRAINT firstkey PRIMARY KEY,
msgnum      integer NOT NULL default '0',
dir      varchar default '',
context      varchar default '',
macrocontext      varchar (80) default '',
callerid      varchar (40) default '',
origtime      varchar (40) default '',
duration      varchar (20) default '',
mailboxuser      varchar (80) default '',
mailboxcontext      varchar (80) default '',
recording      bytea,
UNIQUE      (dir)
);
ALTER TABLE voicemessages ALTER COLUMN recording SET STORAGE EXTENDED;

I'm not sure if I chose the best matching data types in postgresql.

0
Comment
Question by:sean-keys
3 Comments
 
LVL 22

Accepted Solution

by:
earth man2 earned 2000 total points
ID: 20385850
CREATE TABLE voicemessages (
id  bigserial PRIMARY KEY,
msgnum  int NOT NULL default 0,
dir text,
context text,
macrocontext      varchar (80),
callerid      varchar (40),
origtime      varchar (40),
duration      varchar (20),
mailboxuser      varchar (80),
mailboxcontext      varchar (80),
recording      bytea,
CONSTRAiNT UNIQUE (dir)
);
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 20385993
Are you worried about something in particular?  The only real difference I see is that you did not supply a character limit on the varchar fields `dir` and `context`.  

As far as matching data types, the only question would be for longblob.  PostgreSQL states that the bytea type is for long binary storage, and while the type is handled slightly differently than a longblob, the function provided for it are roughly the same.
0
 

Author Comment

by:sean-keys
ID: 20386401
I'm trying to get postgresql to work with asterisk, it uses longblob in mysql for voice mail data.  We'll see what happens.

0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
What we learned in Webroot's webinar on multi-vector protection.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question