Generate an object's DDL (CREATE statement)
Oracle
SELECT DBMS_METADATA.GET_DDL('TABLE', 'EMPLOYEE', 'HR') FROM dual;Use 'INDEX' for indexes, 'PACKAGE' for packages, etc. Prevent long output truncation with SET LONG 100000.
PostgreSQL
-- There is no single function in SQL; from the shell:
pg_dump -t public.customer --schema-only mydbIn psql, \d customer shows the structure readably; for full DDL use pg_dump --schema-only.
MySQL
SHOW CREATE TABLE customer\GReturns the full CREATE TABLE (columns, indexes, engine, charset) in a single command.
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)For a procedure/view body: SELECT OBJECT_DEFINITION(OBJECT_ID('dbo.usp_name'));
MongoDB
// There is no DDL (schemaless). View collection options/validator:
db.getCollectionInfos({ name: "customer" })If options.validator ($jsonSchema) is defined, it is the only 'schema definition'; indexes are retrieved separately with getIndexes().
Redis
# Not applicable: there is no schema/DDL concept.Data structures are defined in application code; persistence is in RDB/AOF files.