Quick SQL
Quick SQL
Quick SQL
Quick SQL provides a quick way to generate the SQL required to create a relational data model from an indented text document. This tool is
designed to reduce the time and effort required to create SQL tables, triggers, and index structures. This tool is not designed to be a replacement for
data modeling, it is simply a quick way to develop a script for simple tables and views. Once the SQL is generated it can be tweaked and expanded
upon.
Datatypes typically default to VARCHAR2, if you want a column of a different datatype add a space NUM, INT, DATE to the
end of a column name. Based on the english text contained in the column name, and in the absence of any datatype specified
the system will make educated deductions for some column names. For example, if the column name contains the word DATE
then it will be a date data type, or if the column name contains the word NUMBER or NUM then it will be a number data type.
If you want to specify a specific VARCHAR2 length enter VCn where "n" is the length of the VARCHAR2. Click the Syntax
button to show available syntax. Object names will be automatically formatted, replacing spaces with underscores, so you can
use spaces in column and table names.
You can automatically add "Who Columns", e.g. who created or last updated a given row and when. You can add a row
sequence column that automatically increments by one on each row update. A row sequence can be useful to simplify lost
update detection. A PL/SQL API can also be generated which provides a package per table and provides procedures to query,
insert, update, and delete rows.
Creating the Database Objects
Once you have completed entering the Quick SQL Shorthand and applied the appropriate settings, you are ready to use the SQL to create
the database objects, and potentially populate the tables with random data. Follow these steps:
Click Save Model to save the Quick SQL shorthand syntax as a model, to reuse in the future.
Enter a model name.
Click Save SQL Script to save the output as a script.
Enter a script name.
Click Review and Run to navigate to the Script Editor.
Within the Script Editor, review the script contents for correctness.
Click Run to create the database objects.
On the script confirmation page, click Run Now.
On the results page review the statements processed, successful, and with errors.
If any errors are reported, navigate through the result pages to see the specific Oracle error messages.
Optionally, click Create App from Script to go to into the the Create App Wizard and have pages automatically generated based on
the tables and views specified in the script.
Data Types
num, number NUMBER
int, integer INTEGER
d, date DATE
ts, timestamp TIMESTAMP
tstz, tswtz, timestamp with local time zone TIMESTAMP WITH LOCAL TIMEZONE
char, vc, varchar, varchar2, string VARCHAR2(4000)
vc32k VARCHAR2(32767)
clob CLOB
blob BLOB
json CLOB CHECK (<Column Name> IS JSON)
Automatically adds an UPDATED, UPDATED_BY, INSERTED, and INSERTED_BY columns and the
/auditcols, /audit cols, /audit columns trigger logic to set column values.
/colprefix Prefix all columns of a given table with this value. Automatically adds an underscore if not provided.
Generate NN SQL INSERT statement(s) with random data, for example: /INSERT 20. (Maximum =
/insert NN
1000)
/rest Generate REST enablement of the table using Oracle REST Data Services (ORDS)
/select Generate SQL SELECT statement after generating data for each table
/constant When generating data set this column to a constant value. For example /constant NYC.
/default Adds default value if the column is null
/values Comma separated list of values to use when generating data. For example /values 1, 2, 3, 4 or /values Yes,
No.
/upper Forces column values to upper case
/lower Forces column values to lower case
/nn, /not null Adds a not null constraint on the column
/between Adds a between check constraint on the column, for example /between 1 and 100
/hidden, /invisible Hidden columns are not displayed using select * from table.
/references, /reference, /fk Foreign key references e.g. /references table_name. Note you can reference tables that are not part of
your model.
/pk Identifies column as the primary key of the table. It is recommended not manually specify primary keys
and let this app create primary key columns automatically.
--, [ comments ] Enclose comments using square brackets or using dash dash syntax
Settings:
You can enter inline settings to explicitly set SQL syntax generation options. Alternatively, you can click Settings at the top of the right pane to
declaratively set the generation options.
Entering settings directly into the Quick SQL Shorthand pane ensures the same SQL generation options are utilized even if you download the script
and later paste it back. For example, enter the following to prefix all table names with TEST and generate for schema OBE:
Alternatively, enter each setting on a separate line for the same result:
# prefix: "test"
# schema: "OBE"
Note: The settings must start on a new line and begin with # settings = to enter multiple settings, or # to enter a single setting per line. All values are
case insensitive. Brackets, spaces, and commas can be added for clarity but are ignored. To have all settings generated use # verbose: true.
Setting Description Example Default
This setting controls the syntax generated to support audit columns. Specifically if audit columns are enabled triggers
are generated to maintain the user creating a row and the user last updating a row. When enabled the following
APEX function is used:coalesce(sys_context('APEX$SESSION','APP_USER'),user)When not enabled the following function is # apex: true false
used:user
API Generate PL/SQL APIs on all tables for create, insert, update, delete and query. # api: true false
AUDITCOLS Adds an additional created, created_by, updated and updated_by columns to every table created. # auditcols: true false
COMPRESS When enabled creates all tables compressed. Default is not compressed. # compress: true false
When Audit Columns are enabled the default column used to track the user who created a row is CREATED_BY. Use this # createdByCol:
CREATEDBYCOL setting to override default audit column name. "created_by_user" created_by
When Audit Columns are enabled the default column used to track the user who created a row is CREATED. Use this # createdCol:
CREATEDCOL created
setting to override default audit column name. "created_date"
DATE By default all DATE columns created using the Oracle DATE datatype. Use this setting to override this default. Valid # date: "timestamp with date
values are:date, timestamp, timestamp with time zone,TSWTZ, timestamp with local time zone, TSWLTZ. local time zone"
DB Specifies the database version the syntax should be compatible with. Valid values are:11g, 12c, 19c, 21c # db: "19c" 21c
DROP Include SQL commands to drop each database object created. # drop: true false
Generate data used for insert statements using this language. The default is English. Supported languages
LANGUAGE include:EN, DE, KO, JA # language: "EN" EN
Setting Description Example Default
Allow longer identifiers to be used for database object names. Longer identifiers allow the maximum length a VARCHAR2
LONGVC column datatype will be 32767 characters. When not set the maximum length of a VARCHAR2 column datatype will be # longVC: true false
4000 characters.
# ondelete:
ONDELETE This setting controls how foreign key ON DELETE settings. Valid values include:cascade, restrict, set null cascade
"cascade"
When enabled all application settings set via the user interface console are ignored and only settings set in the script will be # overrideSettings:
OVERRIDESETTINGS used. true false
Determines how the primary key will be set. Primary keys can be set using SYS_GUID, identity column or sequence. Valid
PK values include:guid, seq, identity # PK: "identity" guid
PREFIX Database object prefix. An underscore will be appended if not provided. # prefix: "foo"
#
PREFIXPKWITHTNAM Prefix primary key database table columns with name of table. For example the primary key of the EMPLOYEE table would prefixPKwithTname: false
E be EMPLOYEE_ID. Without setting the name of implicitly created primary key columns will be ID.
true
GENPK Automatically generate an ID primary key column for each table. # genPK: false true
RESETSETTINGS Resets all application settings to default values. When included all application settings currently active for your session will # resetsettings
be ignored.
For each table created add a ROW_KEY column that generates an alphanumeric identifier. Values of the ROW_KEY column
ROWKEY will be set by generated database table trigger logic. # rowkey: true false
TENANTID For each table add a TENANT_ID column to support mutil-tenant applications. The value of this column is simply added to # tenantID: true false
the table, maintaining this value will need to be provided by the developer.
For each table generated add a ROW_VERSION column that increments by 1 for each update. When enabled database table
ROWVERSION trigger logic will be generated to increment row versions on update. # rowVersion: true false
Setting Description Example Default
SCHEMA Prefix object names with a schema name. The default is no schema prefix for object names. # schema: "scott"
You can choose no column semantics, or BYTE or CHAR semantics.varchar2(4000), varchar2(4000
SEMANTICS byte), varchar2(4000 char) # semantics: "char"
# updatedByCol:
UPDATEDBYCOL When enabling audit columns use this setting to override default audit column name. updated_by
"updated_by_user"
UPDATEDCOL When enabling audit columns use this setting to override default audit column name. # updatedCol: "updated_dt" updated
VERBOSE Will show all settings, not just settings that are different from the default. # verbose: true false