Solved

MYSQL to POSTGRESQL Translation

Posted on 2007-11-30
3
2,432 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 22

Accepted Solution

by:
earth man2 earned 500 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 50

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Read about achieving the basic levels of HRIS security in the workplace.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 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