日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

sql server2008中怎样用sql语句创建数据库和数据表

發(fā)布時(shí)間:2023/12/4 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sql server2008中怎样用sql语句创建数据库和数据表 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

這是簡(jiǎn)單用代碼實(shí)現(xiàn)創(chuàng)建數(shù)據(jù)庫和數(shù)據(jù)表的sql語句,如下:

--調(diào)用系統(tǒng)數(shù)據(jù)庫--

use?master

go

/***防止你要?jiǎng)?chuàng)建的數(shù)據(jù)庫同名,先把它刪除掉****/

if Exists(select * from dbo.sysdatabases where name='TestDB')

begin

  drop database TestDB

end

go

--創(chuàng)建數(shù)據(jù)庫TestDB----

create?databasse TestDB

on(

  --數(shù)據(jù)庫的名稱--

  name='testdb_mdf';

  --設(shè)置數(shù)據(jù)庫存放的路徑--

  filename='D:\SQL\DB\testdb_mdf.mdf';

)

log on(

  name='testdb_ldf';

  filename='D:\SQL\DB\testdb_ldf.ldf';

)

go

/***創(chuàng)建數(shù)據(jù)庫表*****/

---使用新創(chuàng)建的數(shù)據(jù)庫--

use?TestDB

go

--創(chuàng)建Student表--

create table Student(

  --identity(1,1)自增,primary key是主鍵--

  stuId int identity(1,1) primary key,??

  stuName varchar(20) not null,

  stuAge int not null,

  stuSex varchar(2) not null,

  Address varchar(50) not null

)

go

/***數(shù)據(jù)表的添加,查詢。修改、刪除的操作***/

--添加操作--

insert?into Student? values('張三',23,'男',‘廣州’);

insert?into Student(stuName,stuAge,stuSex,Address) values('李四',21,'女',‘海南’);

--查詢操作--

select * from Student;

select * from Student where stuId='2';

--修改操作--

update Student set stuAge=27 where stuId='1';

--刪除操作--

delete from Student where stuId='2'

總結(jié)

以上是生活随笔為你收集整理的sql server2008中怎样用sql语句创建数据库和数据表的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。