show create table for PostgreSQL

  • This SQL function returns a CREATE TABLE statement for the table assigned.
  • PostgreSQL にて CREATE TABLE 文を取得するための SQL 関数です。 PostgreSQL では pg_dump --schema-only コマンドで CREATE TABLE 文を取得できますが、 DB 接続や psql コンソールなどから取得することができません。 本 SQL は、それを実現するためのものです。

Features

  • このファンクションは、SQL文1つから構成されますので、
    • PostgreSQL の設定変更なしに利用することができます。
    • PHP, Java, Ruby 等、お好きな言語に組み込むことができます。
      • 例:1) $1, $2 を言語ごとの変数にする、2) ダブルクオーテーションをエスケープする (" -> \")
  • This function is written in SQL. This brings the features that:
    • You do not need to re-configure your PostgreSQL settings.
    • You can embed this function in your preferred languages: PHP, Java, Ruby, etc...
      • example: 1) replace $1 and $2 into variables of the language you are going to use, 2) escape the double-quotations (" -> \")

Usage

  1. SELECT show_create_table('table_name', 'schema_name');
  2. or
  3. SELECT show_create_table('table_name', null);
  • schema_name を null にすると、全スキーマが検索の対象になります。
  • If schema_name = null, all of the schema will be searched.

Install

  • psql シェルでコピー&ペーストするなどしてください。
  • copy & paste in psql shell.

Available versions

known bugs

Últimos archivo liberados

pgshowcreatetbl (v0.61)2010-09-03 13:27

Recent Tickets

(empty)