Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2011
    Posts
    7

    Unanswered: 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.

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    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


  3. #3
    Join Date
    Aug 2011
    Posts
    7
    Thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •