type of data
Exact numeric
approximate numeric
string of
Unicode strings
**
1. Create a table
create table table name (column name Data type (size), the column name second data type (size) Column Name Data Type 3 (size))
Delete table
drop table <表名>
Add Column
ALTER TABLE table
ALTER COLUMN Column name Data type (size)
Column: alter table www add notes nvarchar (10)
# add a table in the Comments column www
**修改列的数据类型**
ALTER TABLE 表名
ALTER COLUMN Column name Data type (size)
Column: alter table www alter column Remarks nvarchar (1000)
# edit list at www 'Remarks' column data type length of 1000
Remove Columns
ALTER TABLE table
DROP COLUMN column name
column: alter table www drop column Remarks
#www delete table 'Remarks' table name
Insert data
INSERT [INTO] <table name> [Column Name] VALUES <list of values>
column: insert into www values ( '10 ', ' tomato', 'vegetables', '2.1', '2011-10-11')
# in adding a data table www
update data
UPDATE <table name> SET <column name = updated value> [WHERE <update condition>]
- immediately behind the set values of the plurality of data columns can be of a limited
- where to restrictions
columns: update www set the sales price = 1000 where name = 'apple'
#www table update the sales price for the 1000, only the name of Apple's entry into force
delete data
1.delete delete statement
DELETE FROM <table name> [WHERE <Delete condition>]
column: delete from www where name = 'apple'
# delete table inside the www name for Apple's data
2.Truncate Table statement
Truncate Table statement can only be used to delete the entire contents of the table
columns: Truncate the table www
# delete all the contents inside www table
data query
Conditional expression
Comparison operators
wildcard
logical operators
select from www | 查询www表
select 姓名,职务,基本工资 from www | 在www表里查询只显示,姓名,职务,基本工资
select 姓名 from www where 职务=‘财务部’ | www表里查询职务=财务部的员工
select from www where 工资 betweer 8000 and 10000 |查询www表里工资为8000 ~ 10000的员工信息
select from www where 工资 <10000 or 工资 >20000 |查询www表里低于10000或高于20000的员工信息
select from www where 工资 in (8000,9000,10000) |查询www表里工资为 8000,9000,10000的员工信息
select from www where 姓名 like ‘张%’ |查询www表里姓名以张开头的员工信息
select from www where 姓名 like ‘杨%’ and 职务=‘财务部’ |查询www表里姓杨并是财务部的员工
select from www where 爱好 is not null |查询www表里爱好为空的员工信息
select top 5 from www |查询www开头五行数据
select name as name, point of sale as xxx, sales price as ddd from sales | alias settings
select * from www order by base salary desc | www query employee information and descending table displays
select distinct positions from www | www table query What are the duties and remove duplicate
select the name, position, gender into new1 from www | www query table name, title, gender, and found a new table