Solved

MYSQL to POSTGRESQL Translation

Posted on 2007-11-30
3
2,453 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

635 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