- 1、本文档共21页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
SQL语句对一些表与字段的基本操作及提高、技巧(国外英文资料)
SQL语句对一些表与字段的基本操作及提高、技巧(国外英文资料)
A basis,
Note: create a database
The CREATE DATABASE DATABASE - name
Note: delete the database
The drop database dbname
3, note:
The backup of SQL server
- create the device that backs up the data
USE the master
EXEC sp_addumpdevice disk, testBack, c: mssql7backupmynwind_1.dat
- - start backing up
BACKUP the DATABASE pubs TO testBack
Explanation: create a new table
Create table tabname (col1 type1 [not null], col2 type2 [not null],..)
Create a new table based on the existing table:
A: create table tab_new like tab_old (using the old table to create A new table)
B: create table tab_new as select col1, col2... The from tab_old definition only
Note: delete the new table
Drop table tabname
6, note:
Add a column: Alter table tabname add column col type
Note: the column will not be deleted when added. The column and the data type in DB2 are not changed, and the only thing that can change is the length of the varchar type.
7, note:
Add primary key: Alter table tabname add primary key (col)
Explanation: delete the primary key: Alter table tabname drop primary key (col)
8, description:
Create the index: create [unique] index idxname on tabname (col...)
Delete the index: drop index idxname
Note: indexes are immutable and want to change must be deleted.
9, description:
Create the view: create view viewname as the select statement
Delete view: drop view view name
Note: a few simple basic SQL statements
Select * from table1 where scope
Insert into table1 (field1, field2) values (value1, value2)
Delete: delete from table1 where scope
Update: update table1 set field1 = value1 where scope
Search: select * from table1 where field1 like % value1 % - like syntax is subtle, check the information!
Select * from table1 order by field1, field2 [desc]
Total: select count as totalcount from table1
Sum: select sum (field1) as sumvalue from table1
Average: select avg (field1) as avgvalue from table1
Maximum: select Max (field1) as maxvalue from table1
Minimum:
文档评论(0)