- 相關(guān)推薦
計(jì)算機(jī)三級(jí)數(shù)據(jù)庫(kù)技術(shù)SQL基礎(chǔ)知識(shí)點(diǎn)
導(dǎo)語(yǔ):SQL是一種特殊目的的編程語(yǔ)言,是一種數(shù)據(jù)庫(kù)查詢和程序設(shè)計(jì)語(yǔ)言,用于存取數(shù)據(jù)以及查詢、更新和管理關(guān)系數(shù)據(jù)庫(kù)系統(tǒng);同時(shí)也是數(shù)據(jù)庫(kù)腳本文件的擴(kuò)展名。下面是計(jì)算機(jī)三級(jí)數(shù)據(jù)庫(kù)技術(shù)SQL基礎(chǔ)知識(shí)點(diǎn),一起來(lái)學(xué)習(xí)下吧:
1、說(shuō)明:創(chuàng)建數(shù)據(jù)庫(kù)
CREATE DATABASE database-name
2、說(shuō)明:刪除數(shù)據(jù)庫(kù)
drop database dbname
3、說(shuō)明:備份sql server
--- 創(chuàng)建 備份數(shù)據(jù)的 device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:mssql7backupMyNwind_1.dat'
--- 開(kāi)始 備份
BACKUP DATABASE pubs TO testBack
4、說(shuō)明:創(chuàng)建新表
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
根據(jù)已有的表創(chuàng)建新表:
A:create table tab_new like tab_old (使用舊表創(chuàng)建新表)
B:create table tab_new as select col1,col2… from tab_old definition only
5、說(shuō)明:刪除新表
tabname
6、說(shuō)明:增加一個(gè)列
Alter table tabname add column col type
注:列增加后將不能刪除。DB2中列加上后數(shù)據(jù)類型也不能改變,唯一能改變的是增加varchar類型的長(zhǎng)度。
7、說(shuō)明:添加主鍵: Alter table tabname add primary key(col)
說(shuō)明:刪除主鍵: Alter table tabname drop primary key(col)
8、說(shuō)明:創(chuàng)建索引:create [unique] index idxname on tabname(col….)
刪除索引:drop index idxname
注:索引是不可更改的,想更改必須刪除重新建。
9、說(shuō)明:創(chuàng)建視圖:create view viewname as select statement
刪除視圖:drop view viewname
10、說(shuō)明:幾個(gè)簡(jiǎn)單的基本的sql語(yǔ)句
選擇:select * from table1 where 范圍
插入: into table1(field1,field2) values(value1,value2)
刪除: from table1 where 范圍
更新:table1 set field1=value1 where 范圍
查找:select * from table1 where field1 like ’%value1%’ ---like的語(yǔ)法很精妙,查資料!
排序:select * from table1 order by field1,field2 [desc]
總數(shù):select count as totalcount from table1
求和:select sum(field1) as sumvalue from table1
平均:select avg(field1) as avgvalue from table1
最大:select max(field1) as maxvalue from table1
最小:select min(field1) as minvalue from table1
【計(jì)算機(jī)三級(jí)數(shù)據(jù)庫(kù)技術(shù)SQL基礎(chǔ)知識(shí)點(diǎn)】相關(guān)文章:
計(jì)算機(jī)三級(jí)《數(shù)據(jù)庫(kù)技術(shù)》基礎(chǔ)習(xí)題及答案08-23
計(jì)算機(jī)三級(jí)《數(shù)據(jù)庫(kù)技術(shù)》的備考知識(shí)點(diǎn)11-05
2016計(jì)算機(jī)三級(jí)《數(shù)據(jù)庫(kù)技術(shù)》基礎(chǔ)習(xí)題及答案10-28
計(jì)算機(jī)三級(jí)數(shù)據(jù)庫(kù)技術(shù)考前基礎(chǔ)訓(xùn)練試題及答案05-25
2017計(jì)算機(jī)三級(jí)數(shù)據(jù)庫(kù)技術(shù)題庫(kù)06-16
計(jì)算機(jī)三級(jí)《數(shù)據(jù)庫(kù)技術(shù)》備考習(xí)題與答案04-24
2016計(jì)算機(jī)三級(jí)《數(shù)據(jù)庫(kù)技術(shù)》試題及答案10-04
2016計(jì)算機(jī)三級(jí)《數(shù)據(jù)庫(kù)技術(shù)》鞏固練習(xí)06-05
計(jì)算機(jī)三級(jí)考試《數(shù)據(jù)庫(kù)技術(shù)》復(fù)習(xí)重點(diǎn)05-28