- 相關(guān)推薦
關(guān)于sql語(yǔ)句大全
在SQL Server數(shù)據(jù)庫(kù)中,我們?cè)趯?xiě)查詢(xún)語(yǔ)句時(shí),一定要遵循一定的原則才能能夠使SQL語(yǔ)句執(zhí)行起來(lái)更加的高效率,sql語(yǔ)句高效性。本文我們主要就總結(jié)了高性能SQL語(yǔ)句的原則,接下來(lái)就讓我們一起來(lái)了解一下這部分內(nèi)容吧。
1、創(chuàng)建數(shù)據(jù)庫(kù): create database 數(shù)據(jù)庫(kù)名
如:create database student;
2、連接到一個(gè)已經(jīng)存在的數(shù)據(jù)庫(kù): use 數(shù)據(jù)庫(kù)名
如:use student;
3、刪除數(shù)據(jù)庫(kù):drop database 數(shù)據(jù)庫(kù)名
如: drop database student;
4、創(chuàng)建表:create table 表名列名列的數(shù)據(jù)類(lèi)型列的約束])
如:create table stuInfo(stuId int primary key,stuName varchar(20) not null)
5、刪除表: drop table 表名
如: drop table stuInfo;
6、修改表:alter table
給表添加新列: alter table 表名 add 列名列的數(shù)據(jù)類(lèi)型
添加多列,中間用逗號(hào)隔開(kāi)
如:alter table stuInfo add stuGender varchar(10)
修改某列的數(shù)據(jù)類(lèi)型:alter table 表名 modify 列名新數(shù)據(jù)類(lèi)型
如:alter table stuInfo modify stuGender int
修改列名:alter table 表名 change 老列名新列名數(shù)據(jù)類(lèi)型
如:alter table stuInfo change stuName stuAddress varchar(30)
刪除列:alter table 表名 drop 列名
如: alter table stuInfo drop stuGender
7、將創(chuàng)建的表的語(yǔ)句反向?qū)С觯?show create table 表名
8、查詢(xún)表的所有內(nèi)容:select * from 表名
查詢(xún)表的部分內(nèi)容: select 列名列表 from 表名
9、查詢(xún)表結(jié)構(gòu):show columns from 表名
10、插入單行數(shù)據(jù):insert into 表名列名列表) values(值列表)
11、插入多行數(shù)據(jù):作用相當(dāng)于將數(shù)據(jù)從一個(gè)表復(fù)制到另一個(gè)表
insert into 表名 (列名列表) select
如將stuInfo表中的所有的學(xué)生姓名復(fù)制到students表中的stuName列中:insert into students(stuName) select stuName from stuInfo
12、刪除數(shù)據(jù):delete from 表名 where過(guò)濾條件
如刪除stuID為4的人的數(shù)據(jù):delete from stuInfo where stuId=4
【sql語(yǔ)句】相關(guān)文章:
php執(zhí)行sql語(yǔ)句的寫(xiě)法05-16
Java初學(xué)者必看的基礎(chǔ)SQL查詢(xún)語(yǔ)句03-26
php怎么防止sql注入02-04
php防止SQL注入的方法04-22
2017計(jì)算機(jī)二級(jí)MySQL考試SQL查詢(xún)語(yǔ)句大全05-30
計(jì)算機(jī)三級(jí)考試數(shù)據(jù)庫(kù)SQL語(yǔ)句整理08-14
php防止SQL注入的方法分享04-08