sql常用的命令語句有幾條各自的功能分別是什麼

2021-06-17 00:51:14 字數 1197 閱讀 7251

1樓:匿名使用者

常用的也不只這些:

1、說明:建立資料庫

create database database-name

2、說明:刪除資料庫

drop database dbname

3、說明:備份sql server

--- 建立 備份資料的 device

use master

exec sp_addumpdevice 'disk', 'testback', 'c:\mssql7backup\mynwind_1.dat'

--- 開始 備份

backup database pubs to testback

4、說明:建立新表

create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)

根據已有的表建立新表:

a:create table tab_new like tab_old (使用舊錶建立新表)

b:create table tab_new as select col1,col2... from tab_old definition only

5、說明:刪除新表

drop table tabname

6、說明:增加一個列

alter table tabname add column col type

注:列增加後將不能刪除。db2中列加上後資料型別也不能改變,唯一能改變的是增加varchar型別的長度。

7、說明:新增主鍵: alter table tabname add primary key(col)

說明:刪除主鍵: alter table tabname drop primary key(col)

8、說明:建立索引:create [unique] index idxname on tabname(col....)

刪除索引:drop index idxname

注:索引是不可更改的,想更改必須刪除重新建。

9、說明:建立檢視:create view viewname as select statement

刪除檢視:drop view viewname

2樓:匿名使用者

insert 插入

update 更新

delete 刪除

簡單SQL查詢 5,蒐集SQL常用的操作語句

updatexset 單價 case when型別 y.列1 then select 列1from ywhere y.x.when型別 y.列2 then select 列2from ywhere y.x.when型別 y.列3 then select 列3from ywhere y.x.else ...

Sql語句的TOP用法有哪些,Sql語句的TOP用法

top的域名你值得擁有 新國際頂級域,你值得擁有.top top子句用於規定要返copy 回的記錄的數目。對於擁有數千條記錄的大型表來說,top 子句是非常有用的。sqlserver 的語法 select topnumber percent column name s from table name...

常用的DOS命令有哪些,常用Dos命令有哪些

attrib 設定檔案屬性 ctty 改變控制裝置 defrag 磁碟碎片整理 doskey 呼叫和建立dos巨集命令 debug 程式除錯命令 emm386 擴充套件記憶體管理 fc 檔案比較 fdisk 硬碟分割槽 lh loadhigh 將程式裝入高階記憶體 move 移動檔案,改目錄名 mo...