Examples Of Create Table As - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

A row is not returned in this example. Constant 'A' is case sensitive, whereas column 'a' is
insensitive.
SELECT * FROM T WHERE a = 'A';
The row is returned in this example. Both sides are case sensitive.
SELECT * FROM T WHERE a = 'A' (not casesensitive);
A row is not returned in this example. A case sensitive comparison is done since column 'b'
is case sensitive.
SELECT * FROM T WHERE b = 'A';
A row is not returned in this example. A case sensitive comparison is done since column 'b'
is case sensitive.
SELECT * FROM T WHERE b = 'A' (not casesensitive);

Examples of CREATE TABLE AS

This section shows the column attribute rules used to generate and specify the column names
and data types of the table being created.
If column-attributes are not specified, the select list items of the select-query are used
to generate the column names and data attributes of the created table. If the select list item
is a column, then it is used as the name of the created column. For example:
create table t as select a,b from t1
Table t has 2 columns named (a,b) and the same data attributes as columns from table t1.
If the select list item is an expression, it must be renamed with an AS clause. An error is
returned if expressions are not named. For example:
create table t as select a+1 c from t1
Table t has 1 column named (c) and data attribute of (a+1)
create table t as select a+1 from t1
An error is returned, expression must be renamed.
If column-attributes are specified and contains datatype-info, then they override
the attributes of the select items in the select query. These data attributes must be compatible
with the corresponding data attributes of the select list items in the select-query.
create table t(a int) as select b from t1
Table t has one column named "a" with datatype "int".
create table t(a char(10)) as select a+1 b from t1;
An error is returned since the data attribute of column "a", a char, does not match the data
attribute of the select list item "b" a numeric.
If column-attributes are specified and they only contain column-name, then the
specified column-name override any name that was derived from the select query.
create table t(c,d) as select a,b from t1
Table t has 2 columns, c and d, which has the data attributes of columns a and b from table
t1.
If column-attributes are specified, then they must contain attributes corresponding to
all select list items in the select-query. An error is returned, if there is a mismatch.
create table t(a int) as select b,c from t1
An error is returned. Two items need to be specified as part of the table-attributes.
column-attributes must specify either the column-name datatype-info pair or just
the column-name for all columns. You cannot specify some columns with just the name
and others with name and datatype.
CREATE TABLE Statement
79

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Neoview SQL and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents