If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Convert query from MySQL to PostgreSQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-11, 16:22
muisei muisei is offline
Registered User
 
Join Date: Aug 2011
Posts: 7
Convert query from MySQL to PostgreSQL

Hello,
I'm in a process of expanding my app to work with other databases and for that I need to convert the MySQL statements to
DB2, InterBase, Oracle, ODBC, PostgreSQL, SQLite2 and SQLite3.
It should be an easy task because there are only four statements I have to convert:

Code:
SHOW TABLES
Code:
SELECT COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY, COLUMN_DEFAULT, EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='<schema_name>' AND TABLE_NAME='<table_name>'
Code:
SELECT REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME, TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA='<schema_name>' ORDER BY REFERENCED_TABLE_NAME, TABLE_NAME, REFERENCED_COLUMN_NAME, COLUMN_NAME
Code:
SELECT name, param_list FROM mysql.proc WHERE db='<schema_name>' AND type='PROCEDURE'
Would you be so kind to tell me I it is possible to convert those statements to PostgreSQL compatible ones, and if so what is their PostgreSQL equivalent.
Reply With Quote
  #2 (permalink)  
Old 08-25-11, 10:09
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
Postgresql supports the information schema, so the middle two queries should be straightforward. The first and last should also be supported with the information schema...
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
  #3 (permalink)  
Old 08-31-11, 00:50
muisei muisei is offline
Registered User
 
Join Date: Aug 2011
Posts: 7
Thank you very much
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On