分类: 数据库开发技术
2009-08-26 11:09:59
通用语法:
CREATE [TEMP] TABLE table-name
(
column-name
{
datatype
| {BYTE|TEXT} [IN {TABLE | blobspace-name]}]
}
[NOT NULL] [UNIQUE [CONSTRAINT constr-name]][,...]
|
[UNIQUE (unique-column-list) [CONSTRAINT constr-name]][,...]
)
[WITH NO LOG]
[IN dbspace-name] [EXTENT SIZE extent-size]
[NEXT SIZE next-size]
[LOCK MODE {PAGE | ROW }]
其中数据类型主要有(INFORMIX数据库):
SERIAL |
CHAR(n) |
SMALLINT |
DECIMAL(m,n) |
FLOAT |
DATE |
INTEGER |
MONEY(m,n) |
SMALLFLOAT |
INTERVAL |
DATETIME |
VARCHAR |
TEXT |
BYTE |
|
|
例如,创建信用卡保证金分户帐的语句是:
CREATE TABLE ca_eacc
(
ea_org char(10),
ea_sub integer,
ea_accno char(11),
ea_name char(30),
ea_year smallint,
ea_ddate date,
ea_bdate date,
ea_edate date,
ea_eamt decimal(16,2),
ea_sdate date,
ea_flag smallint,
ea_cardno char(16),
ea_woper smallint,
ea_coper smallint,
ea_enterest decimal(16,2)
);
通用语法:
CREATE [UNIQUE|DISTINCT] [CLUSTER] INDEX index-name
ON table-name (column-name [ASC|DESC],...)
例如,对信用卡保证金帐户创建关于机构代码和帐号的唯一索引:
CREATE UNIQUE INDEX ica_eacc on ca_eacc(ea_org,ea_accno);
通用语法:
DROP INDEX index-name
DROP TABLE table-name
通用语法:
SELECT [ALL | DISTINCT | UNIQUE] select-list
FROM [OUTER] table-name [table-alias] [,...]
[WHERE condition]
[GROUP BY column-list] [HAVING condition]
[ORDER BY column-name [ASC | DESC],...]
[INTO TEMP table-name] [WITH NO LOG]
联合查询:
SELECT-statement
[
其中,WHERE conditions定义如下:
expr rel-op expr
expr [NOT] BETWEEN expr AND expr
expr [NOT] IN (items)
column-name [NOT] LIKE "string" [ESCAPE escape-character]
column-name [NOT] MATCHES "string" [ESCAPE escape-character]
expr rel-op {ALL | [ANY | SOME]} (SELECT-statement)
expr [NOT] IN (SELECT-statement)
[NOT] EXISTS (SELECT-statement)
column-name IS [NOT] NULL
例1、简单查询,从保证金分户帐中查找所有帐户余额大于10万元的记录:
例2、联合查询,从保证金分户帐及卡分户帐中查找所有余额大于10万元的记录:
例3、子查询,从保证金分户帐中查找所有在已签到网点开户的记录:
通用语法:
UPDATE table-name SET {column-name = expression [,...]
| {(col-list) | *} = (expr-list)}
[WHERE condition]
通用语法:
INSERT INTO table-name [(column-list)]
{
VALUES (value-list)
|
SELECT-statement
}
通用语法: