DBAtlas · データベース運用アトラス

オブジェクトの DDL(CREATE 文)を生成

Oracle

SELECT DBMS_METADATA.GET_DDL('TABLE', 'EMPLOYEE', 'HR') FROM dual;

インデックスには 'INDEX'、パッケージには 'PACKAGE' などを使用する。長い出力の切り捨ては SET LONG 100000 で防ぐ。

PostgreSQL

-- There is no single function in SQL; from the shell:
pg_dump -t public.customer --schema-only mydb

psql では \d customer で構造を読みやすく表示できる。完全な DDL には pg_dump --schema-only を使用する。

MySQL

SHOW CREATE TABLE customer\G

完全な CREATE TABLE(列、インデックス、エンジン、文字セット)を単一コマンドで返す。

SQL Server

-- T-SQL has no single built-in command. Options:
-- 1) SSMS: right-click > Script Table as > CREATE To
-- 2) EXEC sp_help 'dbo.customer';  (structure summary)
-- 3) mssql-scripter tool (command line)

プロシージャ/ビューの本体: SELECT OBJECT_DEFINITION(OBJECT_ID('dbo.usp_name'));

MongoDB

// There is no DDL (schemaless). View collection options/validator:
db.getCollectionInfos({ name: "customer" })

options.validator ($jsonSchema) が定義されていれば、それが唯一の「スキーマ定義」。インデックスは getIndexes() で別途取得する。

Redis

# Not applicable: there is no schema/DDL concept.

データ構造はアプリケーションコードで定義される。永続化は RDB/AOF ファイルで行われる。

DBAtlas で開く →