GENERATE_DDL_FOR_TABLE

<< Click to Display Table of Contents >>

Navigation:  Streaming SQL Reference Guide > Basic Building Blocks > Functions > Built-in Functions > General Management Functions >

GENERATE_DDL_FOR_TABLE

Previous pageReturn to chapter overviewNext page

Generates DDL for everything in current table or view

Syntax

You can implement this function using the following code:

SELECT STATEMENT FROM

 TABLE(SYS_BOOT.MGMT.GENERATE_DDL_FOR_TABLE(SYS_BOOT.MGMT.GENERATE_DDL_FOR_TABLE(schema_name,table_name));

 

where schema_name is the name of the current schema and table_name is the name of the table or view for which you want to generate DDL.

 

or

SELECT STATEMENT FROM

 TABLE(SYS_BOOT.MGMT.GENERATE_DDL_FOR_TABLE(<schema_name>,<view_name>));

 

5_2_indicator

Version 5.2 Feature

As of version 5.2, you no longer need to use the preface SYS_BOOT.MGMT.

Example

SELECT STATEMENT FROM TABLE(SYS_BOOT.MGMT.GENERATE_DDL_FOR_TABLE('SALES','BIDS_VIEW'));

SELECT STATEMENT FROM TABLE(SYS_BOOT.MGMT.GENERATE_DDL_FOR_TABLE('SALES', 'BIDS'));

'STATEMENT'

'CREATE OR REPLACE STREAM SALES.BIDS ('

'   "time" BIGINT,'

'   "ticker" VARCHAR(5),'

'   "shares" INTEGER,'

'   "price" REAL,'

'   "expiryMs" BIGINT,'

'   "comment" VARCHAR(1024)'

');'

 

 

You can also invoke this function for a view:

SELECT STATEMENT FROM TABLE(SYS_BOOT.MGMT.GENERATE_DDL_FOR_TABLE('SALES', 'TEMPSVIEW'));

'STATEMENT'

'SET SCHEMA 'SALES';'

'CREATE OR REPLACE VIEW SALES.TEMPSVIEW AS'

'select empno, name from temps;'