Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
The following features of the SQL supported by SQL Anywhere are not found in many other SQL implementations.
SQL Anywhere has date, time and timestamp types that includes a year, month and day, hour, minutes, seconds and fraction of a second. For insertions or updates to date fields, or comparisons with date fields, a free format date is supported.
In addition, the following operations are allowed on dates:
date + integer Add the specified number of days to a date.
date - integer Subtract the specified number of days from a date.
date - date Compute the number of days between two dates.
date + time Make a timestamp out of a date and time.
Also, many functions are provided for manipulating dates and times. See SQL functions for a description of these.
SQL Anywhere supports both entity and referential integrity. This has been implemented via the following two extensions to the CREATE TABLE and ALTER TABLE commands.
PRIMARY KEY ( column-name, ... ) [NOT NULL] FOREIGN KEY [role-name] [(column-name, ...)] REFERENCES table-name [(column-name, ...)] [ CHECK ON COMMIT ]
The PRIMARY KEY clause declares the primary key for the relation. SQL Anywhere then enforces the uniqueness of the primary key, and ensure that no column in the primary key contains the NULL value.
The FOREIGN KEY clause defines a relationship between this table and another table. This relationship is represented by a column (or columns) in this table which must contain values in the primary key of another table. The system then ensures referential integrity for these columns - whenever these columns are modified or a row is inserted into this table, these columns are checked to ensure that either one or more is NULL or the values match the corresponding columns in the primary key for some row of the other table. For more information, see CREATE TABLE statement.
SQL Anywhere allows automatic joins between tables. In addition to the NATURAL and OUTER join operators supported in other implementations, SQL Anywhere allows KEY joins between tables based on foreign key relationships. This reduces the complexity of the WHERE clause when performing joins.
SQL Anywhere allows more than one table to be referenced by the UPDATE command. Views defined on more than one table can also be updated. Many SQL implementations do not allow updates on joined tables.
The ALTER TABLE command has been extended. In addition to changes for entity and referential integrity, the following types of alterations are allowed:
ADD column data-type ALTER column data-type DELETE column RENAME new-table-name RENAME old-column TO new-column
The ALTER clause can be used to change the maximum length of a character column and convert from one data type to another. See ALTER TABLE statement.
SQL Anywhere allows subqueries to appear wherever expressions are allowed. Many SQL implementations only allow subqueries on the right side of a comparison operator. For example, the following command is valid in SQL Anywhere but not valid in most other SQL implementations.
SELECT Surname, BirthDate, ( SELECT DepartmentName FROM Departments WHERE EmployeeID = Employees.EmployeeID AND DepartmentID = 200 ) FROM Employees;
SQL Anywhere supports several functions not in the ANSI SQL definition. See SQL functions for a full list of available functions.
When using embedded SQL, cursor positions can be moved arbitrarily on the FETCH statement. Cursors can be moved forward or backward relative to the current position or a given number of records from the beginning or end of the cursor.
SQL Anywhere permits aliased expressions in the select list of a query to be referenced in other parts of the query. Most other SQL implementations do not allow this.
|Envoyer votre avis sur cette page par email.||Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1|