SQL Syntax - more about SQL
来源:互联网 发布:u3软件 编辑:程序博客网 时间:2024/06/06 14:20
1. SQL SELECT INTO Statement
2. SQL INSERT INTO SELECT statement
-- copy one table into a new tableSELECT *INTO newtable [IN externaldb]FROM table1
-- copy only columns into the new tableSELECT colName(s)INTO newtable [IN externabdb]FROM table1;
2. SQL INSERT INTO SELECT statement
-- copy data from one table and insert itinto an existing tableINSERT INTO table2SELECT * FROM table1;INSERT INTO table2 (colnames)SELECT colnames3. SQL CREATE DATABASE statement
-- Create a databaseCREATE DATABASE dbname;
4. SQL CREATE TABLE statement--Create a table in a databaseCREATE TABLE table_name(colname1 data_type(size),colname2 data_type(size),....);5. SQL Constraints--SQL constraint SyntaxCREATE TABLE table_name(column_name1 data_type(size) constraint_name,column_name2 data_type(size) constraint_name,....);
Constraints are followings:
NOT NULL - Indicates that a column cannot store NULL valueUNIQUE - Ensures that each row for a column must have a unique valuePRIMARY KEY - A combination of a NOT NULL and UNIQUE. Ensures that a column (or combination of two or more columns) have an unique identity which helps to find a particular record in a table more easily and quicklyFOREIGN KEY - Ensure the referential integrity of the data in one table to match values in another tableCHECK - Ensures that the value in a column meets a specific conditionDEFAULT - Specifies a default value when specified none for this column
6. SQL CREATE INDEX StatementIndex: created in a table to search/query data more quickly and efficiently.
CREATE INDEX (UNIQUE) index_nameON table_name (colname)7. DROP Statement
--DROP INDEX statement is used to delete an index in a table. --DROP index for SQL SERVERDROP INDEX table_name.index_name--DROP index for MySQLALTER TABLE table_name DROP INDEX index_name
-- DROP databaseDROP DATABASE database_name;--DROP TABLE StatementDROP TABLE table_name-- only delete the data inside the tableTRUNCATE TABLE table_name
8. SQL ALTER TABLE Statement--used to add, delete, or modify columns in an existing table.
--add column in a tableALTER TABLE table_nameADD column_name datatype--delete a columnALTER TABLE table_nameDROP COLUMN column_name
9. SQL AUTO INCREMENT Field-- Auto-increment allows a unique number to be generated when a new record is inserted into a table.
0 0
- SQL Syntax - more about SQL
- SQL Syntax -- More about SQL
- SQL Syntax - SQL FUNCTIONS
- SQL Syntax illustration
- SQL Basic Syntax Principles
- SQL Syntax -- Joins
- Sql connection too more!
- about SQL名词解释
- about sql Injection
- Comparison of SQL syntax[Encyclopedia]
- How to Read SQL Syntax
- SQL Syntax - Some Useful Keywords
- SQL Incorrect syntax near 错误
- Supported syntax of Spark SQL
- 13.5 Prepared SQL Statement Syntax
- About SQL and SQL-Based Management Tools
- About SQL and SQL-Based Management Tools
- About SQL and SQL-Based Management Tools
- 二维几何模板-与圆有关的计算 _long double 版
- jquery操作select(取值,设置选中)
- UVa 10674 Tangents 求两圆公切线
- Java那些事:泛型
- hdu 1023 Train Problem II_出栈方法数_卡特兰数
- SQL Syntax - more about SQL
- SQL中DateTime转换成Varchar样式
- Android界面——ImageView的一些事
- iOS- 给App添加内购& 验证购买iOS7新特性
- Wget用法、参数解释
- LeetCode刷题笔录 Permutaions
- RotatedRect 可选择矩形 的绘制
- 黑马程序员_Foundation框架02_NSString
- Populating Next Right Pointers in Each Node -- LeetCode