SQL Advanced usage constraints, Alter, Create, Drop

2010-06-22  来源:本站原创  分类:Database  人气:324 

SQL PRIMARY KEY constraint

PRIMARY KEY constraint to uniquely identify each record in a database table.

Primary key must contain unique values.

Primary key column can not contain NULL values.

Each table should have a primary key, and each table can have only one primary key.
SQL PRIMARY KEY Constraint on CREATE TABLE

The following SQL in the "Persons" table created in the "Id_P" create PRIMARY KEY column constraint:
MySQL:

CREATE TABLE Persons (Id_P int NOT NULL, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255), PRIMARY KEY (Id_P))

SQL Server / Oracle / MS Access:

CREATE TABLE Persons (Id_P int NOT NULL PRIMARY KEY, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255))

If you need to name PRIMARY KEY constraint, and the number of columns defined for the PRIMARY KEY constraint, please use the following SQL syntax:
MySQL / SQL Server / Oracle / MS Access:

CREATE TABLE Persons (Id_P int NOT NULL, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255), CONSTRAINT uc_PersonID PRIMARY KEY (Id_P, LastName))

SQL PRIMARY KEY Constraint on ALTER TABLE

If the table already exist under the "Id_P" create a PRIMARY KEY constraint column, please use the following SQL:
MySQL / SQL Server / Oracle / MS Access:

ALTER TABLE Persons ADD PRIMARY KEY (Id_P)

If you need to name PRIMARY KEY constraint, and the number of columns defined for the PRIMARY KEY constraint, please use the following SQL syntax:
MySQL / SQL Server / Oracle / MS Access:

ALTER TABLE Persons ADD CONSTRAINT pk_PersonID PRIMARY KEY (Id_P, LastName)

Note: If you use the ALTER TABLE statement to add primary key, must declare the primary key column does not contain a NULL value (the first created in the table).
Revocation of PRIMARY KEY constraint

For revocation of PRIMARY KEY constraint, please use the following SQL:
MySQL:

ALTER TABLE Persons DROP PRIMARY KEY

SQL Server / Oracle / MS Access:

ALTER TABLE Persons DROP CONSTRAINT pk_PersonID

SQL FOREIGN KEY constraint

A table in the FOREIGN KEY points to another table in the PRIMARY KEY.

Let's use an example to explain the foreign key. Consider the following two tables:

"Persons" table:
Id_P LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing

"Orders" table:
Id_O OrderNo Id_P
1778953
2446783
3224561
4245621

Please note that, "Orders" in the "Id_P" out point "Persons" table "Id_P" column.

"Persons" table "Id_P" column is the "Persons" table in the PRIMARY KEY.

"Orders" table "Id_P" column is the "Orders" table in the FOREIGN KEY.

FOREIGN KEY constraints for the prevention of destruction of the connection between the table action.

FOREIGN KEY constraints can also prevent the illegal data into the foreign key column, because it must be that it points to one of the values in the table.
SQL FOREIGN KEY Constraint on CREATE TABLE

The following SQL in the "Orders" table created for the "Id_P" column to create FOREIGN KEY:
MySQL:

CREATE TABLE Orders (O_Id int NOT NULL, OrderNo int NOT NULL, Id_P int, PRIMARY KEY (O_Id), FOREIGN KEY (Id_P) REFERENCES Persons (Id_P))

SQL Server / Oracle / MS Access:

CREATE TABLE Orders (O_Id int NOT NULL PRIMARY KEY, OrderNo int NOT NULL, Id_P int FOREIGN KEY REFERENCES Persons (Id_P))

If you need to name the FOREIGN KEY constraint, and the number of columns defined for the FOREIGN KEY constraint, please use the following SQL syntax:
MySQL / SQL Server / Oracle / MS Access:

CREATE TABLE Orders (O_Id int NOT NULL, OrderNo int NOT NULL, Id_P int, PRIMARY KEY (O_Id), CONSTRAINT fk_PerOrders FOREIGN KEY (Id_P) REFERENCES Persons (Id_P))

SQL FOREIGN KEY Constraint on ALTER TABLE

If the "Orders" table already exist under the "Id_P" create a FOREIGN KEY constraint column, please use the following SQL:
MySQL / SQL Server / Oracle / MS Access:

ALTER TABLE Orders ADD FOREIGN KEY (Id_P) REFERENCES Persons (Id_P)

If you need to name the FOREIGN KEY constraint, and the number of columns defined for the FOREIGN KEY constraint, please use the following SQL syntax:
MySQL / SQL Server / Oracle / MS Access:

ALTER TABLE Orders ADD CONSTRAINT fk_PerOrders FOREIGN KEY (Id_P) REFERENCES Persons (Id_P)

Revocation of FOREIGN KEY constraint

For revocation of FOREIGN KEY constraint, please use the following SQL:
MySQL:

ALTER TABLE Orders DROP FOREIGN KEY fk_PerOrders

SQL Server / Oracle / MS Access:

ALTER TABLE Orders DROP CONSTRAINT fk_PerOrders

SQL CHECK constraint

CHECK constraints to limit the scope of the value of the column.

If the CHECK constraint defined on a single column, then the column only allows certain value.

If the definition of a table CHECK constraint, then this constraint will be given out on values constraints.
SQL CHECK Constraint on CREATE TABLE

The following SQL in the "Persons" table created for the "Id_P" column to create CHECK constraints. CHECK constraint provides "Id_P" column must contain only an integer greater than 0.
My SQL:

CREATE TABLE Persons (Id_P int NOT NULL, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255), CHECK (Id_P> 0))

SQL Server / Oracle / MS Access:

CREATE TABLE Persons (Id_P int NOT NULL CHECK (Id_P> 0), LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255))

If you need to name the CHECK constraints, and CHECK constraints defined for the number of columns, please use the following SQL syntax:
MySQL / SQL Server / Oracle / MS Access:

CREATE TABLE Persons (Id_P int NOT NULL, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255), CONSTRAINT chk_Person CHECK (Id_P> 0 AND City = 'Sandnes'))

SQL CHECK Constraint on ALTER TABLE

If the table already exist under the "Id_P" column to create CHECK constraints, please use the following SQL:
MySQL / SQL Server / Oracle / MS Access:

ALTER TABLE Persons ADD CHECK (Id_P> 0)

If you need to name the CHECK constraints, and CHECK constraints defined for the number of columns, please use the following SQL syntax:
MySQL / SQL Server / Oracle / MS Access:

ALTER TABLE Persons ADD CONSTRAINT chk_Person CHECK (Id_P> 0 AND City = 'Sandnes')

CHECK constraints removed

For revocation of CHECK constraints, please use the following SQL:
SQL Server / Oracle / MS Access:

ALTER TABLE Persons DROP CONSTRAINT chk_Person

SQL DEFAULT Constraint

DEFAULT column constraint is used to insert the default value.

If no other value, then the default value will be added to all the new records.
SQL DEFAULT Constraint on CREATE TABLE

The following SQL in the "Persons" table created for the "City" column to create DEFAULT constraint:
My SQL / SQL Server / Oracle / MS Access:

CREATE TABLE Persons (Id_P int NOT NULL, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255) DEFAULT 'Sandnes')

By using similar GETDATE () This function, DEFAULT constraint can also be used to insert the system value:

CREATE TABLE Orders (Id_O int NOT NULL, OrderNo int NOT NULL, Id_P int, OrderDate date DEFAULT GETDATE ())

SQL DEFAULT Constraint on ALTER TABLE

If the table already exists in the case of the "City" column to create DEFAULT constraint, please use the following SQL:
MySQL:

ALTER TABLE Persons ALTER City SET DEFAULT 'SANDNES'

SQL Server / Oracle / MS Access:

ALTER TABLE Persons ALTER COLUMN City SET DEFAULT 'SANDNES'

DEFAULT constraint removed

For revocation DEFAULT constraint, please use the following SQL:
MySQL:

ALTER TABLE Persons ALTER City DROP DEFAULT

SQL Server / Oracle / MS Access:

ALTER TABLE Persons ALTER COLUMN City DROP DEFAULT

CREATE INDEX statement is used to create the index in the table.

Do not read the entire table in the circumstances, the index enables database applications to find data faster.
Index

You can create an index in the table to query the data more quickly and efficiently.

Users can not see the index, they can only be used to speed up the search / query.

Note: update a table containing the index does not need more than update the index of a table more time, this is because the index itself also needs to be updated. Therefore, the ideal approach is to just search out often (and table) above the index.
SQL CREATE INDEX syntax

In the table to create a simple index. Allows the use of duplicate values:

CREATE INDEX index_name ON table_name (column_name)

Note: "column_name" required in the index column.
SQL CREATE UNIQUE INDEX syntax

In the table to create a unique index. The only index means that two lines can not have the same index value.

CREATE UNIQUE INDEX index_name ON table_name (column_name)

Examples of CREATE INDEX

The regular meeting to create a simple index, named "PersonIndex", LastName column in the Person table:

CREATE INDEX PersonIndex ON Person (LastName)

If you want to index a column of descending value, you can be added after the column names reserved words DESC:

CREATE INDEX PersonIndex ON Person (LastName DESC)

If you want to index more than one column, you can list the columns in parentheses the name, separated by commas:

CREATE INDEX PersonIndex ON Person (LastName, FirstName)

By using the DROP statement, you can easily remove the index, table and database.
SQL DROP INDEX statement

We can use the DROP INDEX command to delete a table index.
For Microsoft SQLJet (as well as Microsoft Access) syntax:

DROP INDEX index_name ON table_name

For MS SQL Server syntax:

DROP INDEX table_name.index_name

For IBM DB2 and Oracle syntax:

DROP INDEX index_name

The syntax for MySQL:

ALTER TABLE table_name DROP INDEX index_name

SQL DROP TABLE statement

DROP TABLE statement is used to remove the table (table structure, attributes, and the index will be deleted):

DROP TABLE table name

SQL DROP DATABASE statement

DROP DATABASE statement is used to delete the database:

DROP DATABASE database name

SQL TRUNCATE TABLE statement

If we only need to remove the table's data, but does not delete the table itself, then we do it?

Please use the TRUNCATE TABLE command (just delete the data in tabular form):

TRUNCATE TABLE table name

ALTER TABLE statement

ALTER TABLE statement for the existing table to add, modify, or delete columns.
SQL ALTER TABLE Syntax

For the table, add columns, please use the following syntax:

ALTER TABLE table_name ADD column_name datatype

To delete a table column, use the following syntax:

ALTER TABLE table_name DROP COLUMN column_name

Note: Some database systems do not allow this to delete columns in a database table manner (DROP COLUMN column_name).

To change the table column data types, please use the following syntax:

ALTER TABLE table_name ALTER COLUMN column_name datatype

The original table (used in the case of):

Persons table:
Id LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing
SQL ALTER TABLE examples

Now, we hope in the table "Persons" add a name "Birthday" of the new column.

We use the following SQL statement:

ALTER TABLE Persons ADD Birthday date

Please note that the new column "Birthday" is of type date, you can store the date. Column data type provides the type of data can be stored.

The new "Persons" table like this:
Id LastName FirstName Address City Birthday
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing
Change the data type instances

Now we want to change the "Persons" table, "Birthday" column data type.

We use the following SQL statement:

ALTER TABLE Persons ALTER COLUMN Birthday year

Please note that, "Birthday" column data type is the year, can hold two or four year format.
DROP COLUMN instance

Next, we remove the "Person" table "Birthday" column:

ALTER TABLE Person DROP COLUMN Birthday

Persons table will be like this:
Id LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing

Auto-increment in the new record will be inserted in the table to generate a unique number.
AUTO INCREMENT field

We usually want to insert a new record every time, automatically creating the primary key field value.

We can create a table auto-increment field.
The syntax for MySQL

The following SQL statement to "Persons" table "P_Id" column is defined as auto-increment primary key:

CREATE TABLE Persons (P_Id int NOT NULL AUTO_INCREMENT, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255), PRIMARY KEY (P_Id))

MySQL uses AUTO_INCREMENT keyword to perform auto-increment task.

By default, AUTO_INCREMENT start value is 1, each increment a new record.

Let the AUTO_INCREMENT value of the starting sequence to the other, use the following SQL syntax:

ALTER TABLE Persons AUTO_INCREMENT = 100

To "Persons" table, insert a new record, we do not have to "P_Id" column provides the value (will automatically add a unique value):

INSERT INTO Persons (FirstName, LastName) VALUES ('Bill', 'Gates')

The above SQL statement will be "Persons" table, insert a new record. "P_Id" will be given a unique value. "FirstName" will be set to "Bill", "LastName" column would be set to "Gates".
The syntax for SQL Server

The following SQL statement to "Persons" table "P_Id" column is defined as auto-increment primary key:

CREATE TABLE Persons (P_Id int PRIMARY KEY IDENTITY, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255))

MS SQL use the IDENTITY keyword to perform auto-increment task.

By default, IDENTITY start value is 1, each increment a new record.

To the provisions of "P_Id" out of 20 initial and 10 increments, please identity to IDENTITY (20,10)

To "Persons" table, insert a new record, we do not have to "P_Id" column provides the value (will automatically add a unique value):

INSERT INTO Persons (FirstName, LastName) VALUES ('Bill', 'Gates')

The above SQL statement will be "Persons" table, insert a new record. "P_Id" will be given a unique value. "FirstName" will be set to "Bill", "LastName" column would be set to "Gates".
The syntax for Access

The following SQL statement to "Persons" table "P_Id" column is defined as auto-increment primary key:

CREATE TABLE Persons (P_Id int PRIMARY KEY AUTOINCREMENT, LastName varchar (255) NOT NULL, FirstName varchar (255), Address varchar (255), City varchar (255))

MS Access AUTOINCREMENT keywords used to perform auto-increment task.

By default, AUTOINCREMENT start value is 1, each increment a new record.

To the provisions of "P_Id" out of 20 initial and 10 increments, please autoincrement to AUTOINCREMENT (20,10)

To "Persons" table, insert a new record, we do not have to "P_Id" column provides the value (will automatically add a unique value):

INSERT INTO Persons (FirstName, LastName) VALUES ('Bill', 'Gates')

The above SQL statement will be "Persons" table, insert a new record. "P_Id" will be given a unique value. "FirstName" will be set to "Bill", "LastName" column would be set to "Gates".
The syntax for Oracle

In Oracle, the code a bit more complicated.

You must create a sequence of the auto-increment field (the object generating digital sequences).

CREATE SEQUENCE, please use the following syntax:

CREATE SEQUENCE seq_person MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10

The above code creates a sequence object called seq_person it to a start and to an increase. The value of the object cache 10 in order to improve performance. CACHE option provides increased access speed to the number of sequence values to be stored.

To "Persons" table, insert a new record, we must use the nextval function (the function to retrieve the next sequence from seq_person a value):

INSERT INTO Persons (P_Id, FirstName, LastName) VALUES (seq_person.nextval, 'Lars', 'Monsen')

The above SQL statement will be "Persons" table, insert a new record. "P_Id" assignment from seq_person next sequence number. "FirstName" will be set to "Bill", "LastName" column would be set to "Gates".
SQL Date data type

MySQL uses the following data types stored in the database date or date / time value:

* DATE - format YYYY-MM-DD
* DATETIME - format: YYYY-MM-DD HH: MM: SS
* TIMESTAMP - format: YYYY-MM-DD HH: MM: SS
* YEAR - format YYYY or YY

SQL Server uses the following data types stored in the database date or date / time value:

* DATE - format YYYY-MM-DD
* DATETIME - format: YYYY-MM-DD HH: MM: SS
* SMALLDATETIME - format: YYYY-MM-DD HH: MM: SS
* TIMESTAMP - format: the only figures

SQL date handling

If the part does not involve time, we can easily compare two dates!

Suppose we have the following the "Orders" table:
OrderId ProductName OrderDate
1 computer 2008-12-26
2 printer 2008-12-26
3 electrograph 2008-11-12
4 telephone 2008-10-19

Now we want to select OrderDate from the table as "2008-12-26" record.

We use the following SELECT statement:

SELECT * FROM Orders WHERE OrderDate = '2008-12-26 '

Result set:
OrderId ProductName OrderDate
1 computer 2008-12-26
3 electrograph 2008-12-26

Now suppose that "Orders" like this (note that "OrderDate" column in the time part):
OrderId ProductName OrderDate
1 computer 2008-12-26 16:23:55
2 printer 2008-12-26 10:45:26
3 electrograph 2008-11-12 14:12:08
4 telephone 2008-10-19 12:56:10

If we use the above SELECT statement:

SELECT * FROM Orders WHERE OrderDate = '2008-12-26 '

Then we get the result. This is because the query does not contain the time portion of date.

Tip: If you wish to query is simple and easier to maintain, then please do not use the time part of date!

Text for text or a combination of text and numbers. Up to 255 characters.
Memo

Memo for the greater number of the text. Store up to 65,536 characters.

Note: Can not sort on memo fields. But they are searchable.

Byte 0 to 255 the number allowed. 1 byte
Integer between allowing a number between -32,768 to 32,767. 2 bytes
Long allowed between -2,147,483,648 and 2,147,483,647 total number of 4 bytes
Single single-precision floating point. Handle most of the decimal. 4 bytes
Double double precision floating point. Handle most of the decimal. 8 bytes
Currency

For money. Support 15 of the yuan, plus four decimal places.

Tip: You can choose which country's currency.
8 bytes
AutoNumber AutoNumber fields automatically assign numbers for each record, usually starting at 1. 4 bytes
Date / Time 8 bytes for the date and time
Yes / No

Logical field, can be displayed as Yes / No, True / False or On / Off.

In the code, use the constants True and False (equivalent to 1 and 0)

Notes: Yes / No field does not allow Null values
1 bit
Ole Object can store images, audio, video or other BLOBs (Binary Large OBjects) up to 1GB
Hyperlink link contains links to other documents, including HTML.
Lookup Wizard allows you to create a list to choose from the following list of options. 4 bytes

MySQL Data Types

In MySQL, there are three main types: text, numbers, and date / time type.
Text type:
Data Type Description
CHAR (size) save a fixed length string (can contain letters, numbers and special characters). Specified in parentheses length of the string. Up to 255 characters.
VARCHAR (size)

Save the variable-length string (can contain letters, numbers and special characters). Specified in parentheses the maximum length of string. Up to 255 characters.

Note: If the value is longer than 255, were converted to TEXT type.
TINYTEXT store 255 characters maximum length of string.
TEXT store 65,535 characters maximum length of string.
BLOB for BLOBs (Binary Large OBjects). Store up to 65,535 bytes of data.
MEDIUMTEXT stored maximum length of 16,777,215 characters of the string.
MEDIUMBLOB for BLOBs (Binary Large OBjects). Store up to 16,777,215 bytes of data.
Maximum length of 4,294,967,295 LONGTEXT stored character string.
LONGBLOB for BLOBs (Binary Large OBjects). Store up to 4,294,967,295 bytes of data.
ENUM (x, y, z, etc.)

Allows you to enter a list of possible values. ENUM is listed in the list of the largest value of 65535. If the list does not exist in the value inserted, then insert a null value.

Note: These values are in accordance with the order you enter is stored.

This format can be imported in accordance with possible values: ENUM ('X', 'Y', 'Z')
Similar to SET and ENUM, SET can only contain a list of 64 items, but the SET can store more than one value.

相关文章
  • SQL Advanced usage constraints, Alter, Create, Drop 2010-06-22

    SQL PRIMARY KEY constraint PRIMARY KEY constraint to uniquely identify each record in a database table. Primary key must contain unique values. Primary key column can not contain NULL values. Each table should have a primary key, and each table can h

  • SQL Advanced Usage (1) 2010-04-12

    SQL> select * from c 2 / ID HY SHF SHL ---------- -------- ------ ---------- 1 Force 30 Beijing 2 Building Beijing 50 3 100 troops in Hubei 4 Construction of Hubei 130 5 Building 60 Shanghai SQL> SQL> select nvl (shf, 'total') "****", s

  • 19.pl/sql Advanced - control structures (branches, circulation, control) 2010-05-12

    Fun combat tutorial oracle (seventh day) Introduction 1. On the section reviews 2.pl/sql Advanced √ 3.oracle view (with security, and simplify complex query functions) √ 4.oracle trigger √ Desired goals 1. Master pl / sql Advanced usage (paging proce

  • PL / SQL, Advanced Query 2011-09-22

    PL / SQL, Advanced Query 1 With clause 1.1 Learning Objectives Master with clause usage, and understand with clause can improve the query efficiency reasons. 1.2 With clause points 1. With the return clause, the result is stored to the user's tempora

  • PL / SQL Advanced Application - collection 2010-12-06

    PL / SQL Advanced Application - collection Readers may ask why you want to use the collection? After all, the use of two tables with foreign keys have been allowed to create data linkages. The answer is: Compared to using two tables, the data stored

  • Failure to create a new SQL server 2005 database to create database failed prompt 'Collation <server default> is not valid' solution 2010-12-11

    First give an error message: Title: Microsoft SQL Server Management Studio Express ------------------------------ Create the database "ddddd" failed. (Microsoft.SqlServer.Express.Smo) For help, click: http://go.microsoft.com/fwlink?ProdName=Micr

  • SQL foreign key constraints 2011-07-11

    SQL foreign key constraints: NO ACTION, CASCADE, SET NULL, SET DEFAULT NO ACTION Specify if you try to delete / modify a line, and the bank's key is the other existing rows in the table referenced by foreign key, then an error and rolls back DELETE /

  • PL / SQL procedures and functions to create and use 2010-06-21

    Procedures and functions by the following four parts: Signature or head Keyword IS or AS Local statement (optional) BEGIN and END the process among the body (including the exception handler) Process simple example: create or replace procedure show_li

  • SQLLDR Advanced Usage 2010-03-22

    load data infile * into table IMPUT_TAB replace fields terminated by ',' trailing nullcols (Deptno "case when: deptno <= 20 then 0 else 1 end", dname, loc "upper (: loc )",-- use function to import the data into a capital letter las

  • Flex 3 Getting Started (18): Building an advanced user interface, drag and drop support added 2010-08-26

    In a typical visual development environment, you can select in the application and drag an object moving back and forth on the screen. Flex Drag and Drop Manager allows users to select an object, such as an element of List control, or a control such

  • Sql advanced application skills 2011-03-16

    / / Get table table column names for SQl server, the oracle database is invalid. SELECT name FROM syscolumns WHERE (id = (SELECT id FROM sysobjects WHERE (id = OBJECT_ID ('table name')))) ORDER BY colid 1 self-connection Select e.last_name employee,

  • In Oracle sql * loader usage 2011-04-14

    1, File -> Save As: test.txt Save as type tab-delimited 2, create a SQL * LOAD input data required to file with Notepad to edit the control file name is: input.ctl as follows: load data ------ control file identifies the infile 'test.txt' ------ file

  • MySQL usage of alter Summary 2011-07-07

    1: Delete Column ALTER TABLE [table name] DROP [column name] 2: Increase the column ALTER TABLE [table name] ADD [column name] INT NOT NULL COMMENT 'Notes' ALTER TABLE [table name] ADD [column name] INT NOT NULL COMMENT 'Notes', ADD 2] [column name I

  • pl / sql developer execute scripts to create stored procedures 2011-09-05

    pl / sql developer to create a stored procedure tips 1.sql script ready sql script editor, when the stored procedure must be added after each ending in "/." (2) the implementation process The script to execute in the command window, or create a

  • Sql Server 创建数据库脚本Create DATABASE 2015-04-29

    这篇文章主要介绍了Sql Server 创建数据库脚本语句Create DATABASE的使用,需要的朋友可以参考下 Create DATABASE HappyRelaxDB on( NAME='HappyRelaxDB',FILENAME='D:\Sunny_Project\HappyRelaxPro\HappyRelaxDB.mdf') LOG ON(NAME='HappyRelaxDB_log',FILENAME='D:\Sunny_Project\HappyRelaxPro\HappyR

  • SQL Advanced - top. Like. Wildcard 2011-01-04

    TOP clause TOP clause is used to provide for the number of records returned. Thousands of records for a large table for, TOP clause is very useful. Note: Not all database systems support TOP clause. SQL Server syntax: SELECT TOP number | percent colu

  • Lucene search syntax similar to SQL syntax, usage of IN 2010-11-03

    Today explore a SQL-like syntax in Lucene usage IN: ID: (XZXT_009_XZ_XXKW_79563842107502 OR XZXT_009_XZ_XXKW_77144338881602 OR XZXT_009_XZ_XXKW_59998214491402 OR XZXT_009_XZ_XXKW_86645151264302 OR XZXT_009_XZ_XXKW_66009723045802 OR XZXT_009_XZ_XXKW_1

  • Start Sql Advanced Configuration 2011-02-18

    - Before the amendment fails - Exec xp_cmdshell 'md e: \ 123' --******************* Start xp_cmdshell function ************************** ********************* - 1, the first show advanced option is set to 1, will display advanced configuration optio

  • PL / SQL Advanced Control statements 2011-04-17

    • Introduction In any computer language (C, JAVA, pascal) has a variety of control statements (conditional statements, looping structures, sequence control structure) in pl / sql in the existence of such control structures. 1>: Using a variety of if

  • UNION and UNION ALL SQL statement usage 2011-06-07

    The UNION operator is used to merge two or more SELECT statements set UNION operator to select different values. If you allow duplicate values, use the UNION ALL UNION / UNION ALL result set column names are always equivalent to a UNION SELECT statem