Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

.sch SQL schema files

 

.sch files represent SQL database schema. These files are included into target application with various definitions of .sch "keywords" to provide

 

SqlId constants

S_type structures to map table rows into C++ structure

.sql scripts to create/upgrade/drop the schema

 

Example of .sch content:

 

TABLE_(DEMO)

    INT_(ID) PRIMARY_KEY AUTOINCREMENT

    STRING_(UN, 200) UNIQUE

    STRING_(W, 200) INDEX

    INT_ (F_ID) REFERENCES(TABLE2)

END_TABLE

 

All .sch keywords that contain the name of table, type or column, have two variants - simple and with '_' posfix (e.g. TABLE and TABLE_). Variant with '_' postfix also generates global SqlId variable that has the same name and value as is the name of table/type/column (content can be altered with SQL_NAME). This prepares column and table names to be used with SQL expressions.

 

Most column definition keywords come with ARRAY variant, this is not using any SQL engine array capabilities but rather inserts array size count of items with special names to emulate the fixed array.

 

List of .sch file keywords:

 

TABLE(table)

Defines a new table. This creates S_ structures to map SQL table to C++ structure, introspection records and also can create SQL schema creation/upgrade scripts.

TABLE_I(table, base1)

Defines a new table which also has all columns of base1 which can be either table or type.

TABLE_II(table, base1, base2)

Defines a new table which also has all columns of base1 and base2 which can be either tables or types.

TABLE_III(table, base1, base2, base3)

Defines a new table which also has all columns of base1 , base2 and base3 which can be either tables or types.

END_TABLE

Ends table definition.

TYPE(type)

Defines a new type. Unlike TABLE, TYPE does not produce table creation code in schema sql scripts. Following this header is a list of columns and inline attributes, ending with END_TYPE.

TYPE_I(type, base)

Defines a new type which also has all columns of base.

TYPE_II(type, base1, base2)

Defines a new type which also has all columns of base1 and base2.

TYPE_III(type, base1, base2, base3)

Defines a new type which also has all columns of base1 , base2 and base3.

END_TYPE

Ends type definition.

SQL_NAME(id)

Provides an alternate SQL name of previous item. When used, the column name will be used in C++ context, while this alternate name will be use in SQL context. id is C literal.

 

 

INT(column_name)

Column capable of storing 32-bit integer value, int type in C++.

INT_ARRAY(column_name, items)

Array of 32-bit integers.

INT64(column_name)

Column capable of storing 64-bit integer value, int64 type in C++. [sqlite3]

INT64_ARRAY(column_name, items)

Array of 64-bit integers. [sqlite3]

DOUBLE(column_name)

Column capable of storing double precision floating point value, double type in C++.

DOUBLE_ARRAY(column_name, items)

Array of double values.

STRING(column_name, maxlen)

Column capable of storing string with character count limit maxlen, String type in C++.

STRING_ARRAY(column_name, n, items)

Array of strings.

DATE(column_name)

Column capable of storing calendar date (without time), Date type in C++.

DATE_ARRAY(column_name, items)

Array of dates.

TIME(column_name)

Column capable of storing calendar date with time, Time type in C++.

TIME_ARRAY(column_name, items)

Array of date-times.

BOOL(column_name)

Column capable of storing boolean value, bool type in C++. Important: for compatibility reasons between various SQL engines, BOOL is always emulated with single character text value ("1" for true). Conversion is provided for S_ types, but SQL commands must account for this.

BOOL_ARRAY(column_name, items)

Array of bools.

BIT

0 or 1. C++ type is int. [mssql]

BIT_ARRAY

Array of 0 or 1. [mssql]

BLOB(column_name)

Binary data of unlimited size. C++ type is String.

CLOB(column_name)

Text of unlimited size. C++ type is String. [mysql] [postgresql] [oracle]

SERIAL(column_name)

PostgreSQL serial type (equivalent of autoincrement in some other SQL engines). Database type is 32-bit unsigned integer, C++ type is int64.

ISERIAL(column_name)

PostgreSQL serial type with int as C++ type.

BIGSERIAL(column_name)

PostgreSQL 64-bit bigserial type with int64 as C++ type.

NOT_NULL

Not null constraint.

PRIMARY_KEY

Primary key column.

AUTO_INCREMENT

Autoincrement column. [sqlite3] [mysql]

REFERENCES(table)

Foreign key specification for column.

REFERENCES_CASCADE(table)

Foreign key with "ON DELETE CASCADE" option. [sqlite3]

DUAL_PRIMARY_KEY(column1, column2)

Dual primary key for table.

SQLDEFAULT(v)

Default value for column. [sqlite3] [mysql] [postgresql]

INDEX

Column has index.

PARTIAL_INDEX(condition)

Column has partial index. [postgresql]

PARTIAL_INDEX_(constraint_name, condition)

Column has named partial index. [postgresql]

UNIQUE

Column has UNIQUE constraint.

UNIQUE_LIST(constraint_name, list)

Creates UNIQUE constraint for set of columns. list is a C literal with comma separated column names.

DUAL_UNIQUE(column1, column1)

UNIQUE constraint for two columns.

INDEX_LIST(constraint_name, list)

list is a C literal with comma separated column names. [sqlite3]

CHECK_IN(list)

Constraints column's value to a list, which is comma separated C literal. [sqlite3]

CHECK_COND(condition)

Constraints column's value to satisfy a condition, which is C literal with expression. [sqlite3]

SQLCHECK(constraint_name, check)

Adds named CHECK constraint, check is C literal with check expression. [sqlite3] [postgresql] [mssql]

INNODB

Table has INNODB type. [mysql]

SEQUENCE(sequence_name)

Sequence. [postgresql] [mssql] [oracle]

COMMEN(comment)

Inserts a comment into the script.

 

 

 

 

Last edit by cxl on 02/01/2020. Do you want to contribute?. T++