Creates a new table.
Category: | Data Definition |
Restriction: | Constraint syntax is defined by the data source. The constraint syntax provided here is a general syntax. For complete constraint syntax, see the documentation for your datasource. The SPD Engine data source does not support constraints. |
Supports: | EXECUTE Statement |
Data source: | SAS data set, SPD Engine data set, SASHDAT file, Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Note: | Braces in the syntax convention indicate a syntax grouping. The escape character ( \ ) before a brace indicates that the brace is required in the syntax. Table options must be contained by braces ( { } ). |
specifies a table to modify. table can be one of these forms
is an implementation of the ANSI SQL standard for an SQL catalog. The catalog is a data container object that groups logically related schemas. The catalog is the first-level (top) grouping mechanism in a data organization hierarchy that is used along with a schema to provide a means of qualifying names. A catalog is a metadata object in a SAS Metadata Repository.
is an implementation of the ANSI SQL standard for an SQL schema The schema is a data container object that groups files such as tables and views and other objects supported by a data source such as stored procedures. The schema provides a grouping object that is used along with a catalog to provide a means of qualifying names.
is the name of the table.
Requirement | Table naming conventions are based on the data source. When more than one data source is involved, the maximum length of a table name is determined by the maximum length that is supported by all of the data sources and FedSQL. For example, if your data sources are a SAS data set that has a maximum of 32 characters and MySQL that has a maximum of 64 characters, the maximum length of a table name is 32 characters. For more information, see the documentation for your data source. |
specifies to test the performance of creating a table using the AS query-expression clause. FedSQL creates the table internally as if it were to be saved, writing the normal progress messages. The table creation appears to be successful. Once the query expression is complete, the table is discarded.
Interaction | A SELECT select-list FROM _NULL_ statement returns an error. |
specifies one or more table options and their respective values to apply to the table.
Requirement | The OPTION argument and all table options must be enclosed in braces ( { } ). |
See | FedSQL Statement Table Options |
specifies to create a new table from an existing table by selecting rows from the existing table using a query expression. The column attributes, such as formats and labels, are copied from the existing table to the new table.
specifies the SELECT statement that retrieves information from an existing table to use in creating a new table.
Requirement | The number of columns used in the SELECT statement must equal the number of columns in the table. |
See | Creating and Populating Tables from a Query Expression |
Query Expressions and Subqueries | |
SELECT Statement |
Data source | SAS data set, SPD Engine data set, Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MDS, MySQL, Netezza, ODBC, Oracle, SAP HANA, Sybase IQ, Teradata |
specifies the name of the column. The column name is either a local or schema qualified name, using one of these forms:
is an implementation of the ANSI SQL standard for an SQL schema. The schema is a data container object that groups files such as tables and views and other objects supported by a data source such as stored procedures. The schema provides a grouping object that is used along with a catalog to provide a means of qualifying names.
is the name of the column.
Restriction | For SAS data sets and SPD Engine data sets, the column name cannot be longer than 32 characters. |
Requirement | When more than one data source is involved, the maximum length of a column name is determined by the maximum length that is supported by all of the data sources and FedSQL. For example, if your data sources are a SAS data set that has a maximum of 32 characters and MySQL that has a maximum of 64 characters, the maximum length of a column name is 32 characters. Each column in a table must be unique. |
See | For column name requirements, see the documentation for your data source. |
specifies the type of data that the column can store. If the column definition is for a SAS data set or an SPD Engine data set, and the data type is other than CHAR or DOUBLE, FedSQL converts character data types to a CHAR and numeric data types to DOUBLE. FedSQL supports the following table data types:
stores a large signed, exact whole number.
Range | -9,223,372,036,854,775,808 to 9,233,372,036,854,775,807 |
Data source | Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 8 bytes |
stores varying-length binary data.
specifies the maximum number of bytes that can be used to store the binary data. The number of bytes that are used to store the binary data is the number of bytes that are necessary to represent the binary data, up to n bytes.
Range | |
Data source | DB2 under UNIX and PC, Hive, MDS, ODBC, SAP HANA, Sybase IQ |
Storage size | up to n bytes |
stores a fixed-length character string.
specifies the number of bytes that are used to store the character string. If the character string is less than n bytes, the value is right-padded with spaces.
specifies character set encoding information for CHAR data types.
Default | Default encoding depends on your operating system and locale. |
Restriction | SAS data sets, SPD Engine data sets, and SASHDAT files do not support the use of CHARACTER SET "character-set-identifier". SASHDAT files use the encoding specified in the connection string. If the encoding option is not specified, the encoding defaults to the character set associated with the operating system for SAS Federation Server. |
See | LOCALE= Values and Default Settings for ENCODING, PAPERSIZE, DFLANG, and DATESTYLE Options in SAS National Language Support (NLS): Reference Guide |
Alias | CHARACTER(n) |
Requirement | n must be specified. |
Data source | SAS data set, SPD Engine data set, SASHDAT file, DB2 under UNIX and PC, Greenplum, HDMD, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Teradata |
Storage size | n bytes |
stores a date value in the format yyyy-mm-dd.
Requirement | Input values must be specified as a DATE constant. For more information, see FedSQL Date, Time, and Datetime Constants. |
Data source | SAS data set, SPD Engine data set, SASHDAT file, Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 8 bytes |
stores a signed, fixed-point decimal number.
Alias | NUMERIC |
Data source | Aster, DB2 under UNIX and PC, Greenplum, Hive, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 8 bytes |
stores a signed, approximate, floating point number.
Alias | DOUBLE PRECISION |
Data source | SAS data set, SPD Engine data set, SASHDAT file, Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 8 bytes |
stores a signed, approximate, single-precision or double-precision, floating point number. The user-specified precision determines whether the data type stores a single precision or double precision number. If the specified precision is equal to or greater than 25, the value is stored as a double precision number, which is a DOUBLE. If the specified precision is less than 25, the value is stored as a single precision number, which is a REAL.
specifies the maximum number of digits in the floating point number.
Data source | SAS data set, SPD Engine data set, Aster, DB2 under UNIX and PC, Greenplum, Hive, MySQL, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 4 bytes |
Tip | If p is not specified, a DOUBLE is used. |
stores an exact whole number.
Range | -2,147,483,648 to 2,147,483,647 |
Data source | SAS data set, SPD Engine data set, Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 4 bytes |
stores a fixed-length character string by using the Unicode national character set.
specifies the maximum number of multibyte characters that are used to store the character string. If the character string is less than n bytes, the value is right-padded with spaces.
Requirement | n must be specified. |
Data source | Aster, DB2 under UNIX and PC, MDS, MySQL, ODBC, Oracle, SAP HANA, Sybase IQ |
Storage size | n bytes. Depending on the operating system, Unicode characters use either 2 or 4 bytes per character and support all international characters. |
stores a signed, fixed-point decimal number.
Alias | DECIMAL |
Data source | Aster, DB2 under UNIX and PC, Greenplum, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, Sybase IQ, Teradata |
Storage size | 8 bytes |
stores a varying-length character string by using the Unicode national character set.
specifies the maximum number of multibyte characters that can be used to store the character string. The number of bytes that are stored is the actual number of characters specified, up to n bytes.
Requirement | n must be specified. |
Data source | DB2 under UNIX and PC, MDS, ODBC, Oracle, Netezza, SAP HANA, Sybase IQ |
Storage size | up to n bytes. Depending on the platform, Unicode characters use either 2 or bytes per character and can support all international characters. |
stores a signed, approximate, single-precision, floating-point number.
Requirement | |
Data source | SAS data set, SPD Engine data set, Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MySQL, Netezza, Oracle, PostgreSQL, SAP HANA, Sybase IQ |
Storage size | 4 bytes |
stores a small signed, exact whole number.
Range | -32,768 to 32,767 |
Data source | SAS data set, SPD Engine data set, Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MySQL, Netezza, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 2 bytes |
stores a time value with seconds precision.
p | specifies 0–6 digits to use for the precision of a fraction of a second. |
Requirement | Input values must be specified as a TIME constant. For more information, see FedSQL Date, Time, and Datetime Constants. |
Data source | SAS data set, SPD Engine data set, SASHDAT file, Aster, DB2 under UNIX and PC, Greenplum, HDMD, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 8 bytes |
stores both the date and time value with seconds precision.
p | specifies 0–6 digits to use for the precision of a fraction of a second. |
Requirement | Input values must be specified as a TIMESTAMP constant. For more information, see FedSQL Date, Time, and Datetime Constants. |
Data source | SAS data set, SPD Engine data set, SASHDAT file, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | 8 bytes |
stores a very small signed exact, whole number.
Range | -128 to 127 |
Data source | SAS data set, SPD Engine data set, HDMD, Hive, MySQL, Netezza, ODBC, Oracle, SAP HANA, Sybase IQ, Teradata |
Storage size | 1 byte |
stores varying-length binary data.
specifies the maximum number of bytes that can be used to store the binary data. The number of bytes that are used to store the binary data is the number of bytes that are necessary to represent the binary data, up to n bytes.
Range | |
Data source | DB2 under UNIX and PC, MDS, ODBC, Oracle, SAP HANA, Sybase IQ, Teradata |
Storage size | up to n bytes |
stores a varying-length character string.
specifies the number of bytes used to store the character string. The number of bytes that are stored is the actual number of characters, up to n bytes.
specifies character set encoding information for CHAR data types.
Default | Default encoding depends on your operating system and locale. |
See | LOCALE= Values and Default Settings for ENCODING, PAPERSIZE, DFLANG, and DATESTYLE Options in SAS National Language Support (NLS): Reference Guide |
Data source | Aster, DB2 under UNIX and PC, Greenplum, HDMD, Hive, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
Storage size | up to n bytes |
specifies to place an integrity constraint on the column.
Data source | SAS data set, DB2 under UNIX and PC, MDS, MySQL, ODBC, Oracle, SAP HANA, Teradata |
See | <column-constraint> and <table-constraint> Arguments |
Integrity Constraints |
for each row that is added to the table, specifies a value for the column that is assumed when no other value is entered for that column.
specifies the default value.
Requirement | value must be in the range of the specified data type. |
Data source | DB2 under UNIX and PC, MySQL, ODBC, Oracle, SAP HANA, Teradata |
specifies a clause that is used to associate a format, informat, or label with the column.
specifies a SAS data format that is stored as column metadata. The format is not applied to the column data until execution time.
specifies a valid SAS data format. If the format is a format other than a FedSQL or DS2 format, it must be a valid format for the Base SAS.
See | FedSQL Formats, |
DS2 Formats in SAS DS2 Language Reference | |
Dictionary of Formats in SAS Formats and Informats: Reference |
Restriction | Formats that are created by PROC FORMAT cannot be stored as column metadata. |
Note | When you create a table, you can associate a SAS data format with a column. The format is not validated or applied to the column until execution time, such as in a PUT function. If the format is applied to the column in a Base SAS environment, any format can be stored with the column. If the format is applied to the column in the FedSQL environment, the format must be a valid FedSQL or DS2 format. |
specifies a SAS data informat that is stored as column metadata. The informat is not applied to the column data. No validation is done on the informat; it is only informational.
specifies a SAS data informat.
See | FedSQL Informats |
Dictionary of Informats in SAS Formats and Informats: Reference |
specifies a text string to use as an alternate column heading that appears in place of the column name in a query expression result.
Range | 1 - 255 characters |
Restriction | A label can be created only with the CREATE TABLE statement and it cannot be used in a query expression operation. |
Requirement | text-string must be enclosed in either double or single quotation marks. If text-string contains a single quotation mark, enclose text-string in double quotation marks. |
Data source | SAS data set, SPD Engine data set |
begins a column constraint or a table constraint.
Data source | SAS data set, DB2 under UNIX and PC, MDS, MySQL, ODBC, Oracle, SAP HANA, Teradata |
specifies a name to identify the constraint.
See | For constraint name requirements, see the documentation for your data source. |
specifies a condition for values in the column or table. search-condition is a valid FedSQL expression that resolves to a Boolean value. If search-condition is false, no changes are made to the table.
Restriction | For a SAS data set, the search condition cannot contain FedSQL functions. |
Data source | SAS data set, Aster, DB2 under UNIX and PC, Greenplum, MySQL, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
See | FedSQL Expressions |
specifies that, for each row in the table, the value in the column can be used to uniquely identify its respective row in the table. It is a value that does not change. A primary key cannot have a null value.
Data source | SAS data set, Aster, DB2 under UNIX and PC, Greenplum, MySQL, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
specifies that, for each row in the table, the values for all of the columns specified are used to uniquely identify its respective row in the table. A primary key cannot have a null value and it must be unique for each row in the column. It is a value that does not change.
Data source | SAS data set, Aster, DB2 under UNIX and PC, Greenplum, MySQL, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
specifies that no two rows in the column can have the same value. A null value is allowed unless you specify NOT NULL.
Data source | SAS data set, DB2 under UNIX and PC, MySQL, ODBC, Oracle, PostgreSQL, SAP HANA, Teradata |
specifies that no two rows in any of the specified columns can have the same value. A null value is allowed unless you specify NOT NULL.
Data source | SAS data set, Aster, DB2 under UNIX and PC, Greenplum, MySQL, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
specifies that a null value is not valid in any row for the specified column.
Data source | SAS data set, Aster, DB2 under UNIX and PC, Greenplum, MDS, MySQL, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
specifies the clause that relates columns in table to columns in another table through the values for those columns. Foreign keys must always include enough columns to uniquely identify a row in the referenced table. Foreign key constraints help ensure the integrity of related data in multiple tables.
begins the clause that identifies one or more columns in table that relate to columns in another table.
Data source | Aster, DB2 under UNIX and PC, Greenplum, MySQL, ODBC, Oracle, PostgreSQL, SAP HANA, Sybase IQ, Teradata |
specifies the columns in table that relate to columns in another table.
begins the clause that identifies the columns in another table.
specifies the table whose columns relate to columns in table.
specifies one or more columns in the referenced table that relate to the columns in table.
specifies the action to take in the referenced table when columns in table are updated or deleted.
specifies the clause for the action to take when a column in table is updated.
specifies the clause for the action to take when a column in table is deleted.
specifies the action to take when a column in table is updated or deleted.
ON UPDATE, specifies to update all rows in table that reference an updated value in the referenced table. ON DELETE, removes all rows in table that reference the deleted rows in the referenced table.
specifies to set the referenced columns to a null value.
specifies to set the referenced columns to their default value.
specifies that if the referential constraint is not satisfied at any time while the FedSQL statement is processing, no action is taken and the update or deletion fails.
specifies that if the referential constraint is not satisfied at the end of the FedSQL statement, no action is taken and the update or deletion fails.
specifies when the constraint is checked:
specifies whether the constraint violation check can be performed after the transaction completes or if it must be checked at the end of each FedSQL statement. If DEFERRABLE is specified, the constraint check can occur at the end of the transaction. If NOT DEFERRABLE is specified, the constraint must be checked when the FedSQL statement terminates. Specifying DEFERRABLE is useful when more than one statement is necessary to complete a transaction.
Default | DEFERRABLE |
specifies that the constraint violation check is deferred, by default, at the beginning of each transaction and it does not occur until the end of a transaction.
specifies that the constraint violation check occurs at the end of each FedSQL statement.
saleenddate double not null having format date7.;
saledates double having informat anydtdte14.;
create table customers ( custid double primary key, name char(16), address char(64), city char(16), state char(2), country char(16), phone char(16), initorder date having label 'Initial Order' );
Initial Order
is
used in place of the column name initorder
.
create table spainEmails as select name, emailid, lastPurchaseDate from corpdata where country='Spain';
create table spain as select * from corpdata where country='Spain';
create table _null_ as select * from corpdata where country='Spain';FedSQL performs normal processing to create the table and the table appears to be created. The table is discarded when the query is complete.
create table products (prodid double primary key, product char(8) unique not null initially deferred);
create table custcredit (name char(30), custNum double, ccType char(15) having label 'Credit Card Type', ccNum char(20) having label 'Credit Card Number', ccExp date having label 'Expiration Date', CONSTRAINT ccconst primary key(name, CustNum));When FedSQL encounters a DATE data type for a SAS data set, it does a type conversion from DATE to DOUBLE and assigns the DATE9. format to the column.