自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

sql server create語句實例

數(shù)據(jù)庫 SQL Server
在SQL語言中,create語句即可以創(chuàng)建數(shù)據(jù)庫,也是可以創(chuàng)建表,是SQL語句中最重要也是最常用的語句,下面就將為您介紹一個使用create語句創(chuàng)建數(shù)據(jù)庫的例子,供您參考。

sql server create語句用于創(chuàng)建數(shù)據(jù)庫和表,下面就將為您介紹使用sql server create語句創(chuàng)建數(shù)據(jù)庫的實例,供您參考,希望對您更深入了解sql server create語句有所幫助。

  1. use master --切換到master數(shù)據(jù)庫   
  2. go   
  3. --檢測是否存在同名的數(shù)據(jù)庫   
  4. if exists(select 1 from sysdatabases where name = 'tour')   
  5. begin   
  6.   drop database tour   
  7. end   
  8. go   
  9. create database tour   
  10. on --數(shù)據(jù)文件   
  11. (   
  12.   name = 'tour_mdf', --數(shù)據(jù)文件邏輯名   
  13.   filename = 'D:\tour.mdf',--數(shù)據(jù)文件存放路徑   
  14.   size = 1MB,--初始大小   
  15.   maxsize = 10MB,--最大大小   
  16.   filegrowth = 1MB--增長速度   
  17. )   
  18. log on --日志文件   
  19. (   
  20.   name = 'tour_ldf', --日志文件邏輯名   
  21.   filename = 'D:\tour.ldf',--日志文件存放路徑   
  22.   size = 1MB,--初始大小   
  23.   maxsize = 10MB,--最大大小   
  24.   filegrowth = 1MB--增長速度   
  25. )   
  26. go   
  27. use tour   
  28. go   
  29. 創(chuàng)建數(shù)據(jù)庫表   
  30. if exists(select * from sysobjects where name='stuInfo') drop table stuInfo   
  31. create table   stuInfo    /*-創(chuàng)建學(xué)員信息表-*/   
  32. (   
  33.  
  34. stuNo   varchar(6) not null unique,   --學(xué)號,非空(必填)   
  35. stuName  varchar(20) not null ,  --姓名,非空(必填)   
  36. stuAge  int  not null,  --年齡,INT類型默認(rèn)為4個字節(jié)   
  37. stuID  NUMERIC(18,0),     --身份證號   
  38. stuSeat   int  IDENTITY (1,1),   --座位號,自動編號   
  39. stuAddress   text   --住址,允許為空,即可選輸入   
  40. )   
  41. go   
  42.  
  43. if exists(select * from sysobjects where name='stuMarks') drop table stuMarks   
  44. create table  stuMarks   
  45. (   
  46. ExamNo  varchar(6)  not null foreign key references stuInfo(stuNo) ,  --考號   
  47. stuNo  varchar(6) not null,   --學(xué)號   
  48. writtenExam  int  not null,  --筆試成績   
  49. LabExam  int  not null    --機試成績   
  50. )   
  51. go   
  52.  
  53. if exists(select * from sysobjects where name='users') drop table users   
  54. create table users   
  55. (   
  56.     userID int not null primary key identity(1,1),   
  57.     userName varchar(255) not null unique,   
  58.     userPWD varchar(255) not null,   
  59.     userAge int,   
  60.     userBirthDay datetime,   
  61.     userEmail varchar(255)   
  62. )   
  63. go  

 

 

 

【編輯推薦】

強制關(guān)閉SQL Server數(shù)據(jù)庫連接的方法

sql server字符串的類型

sql server字符串函數(shù)分類詳解

sql server端口的更改方法

sql server日志文件過大的解決辦法

責(zé)任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-10-21 14:27:35

SQL Server時

2010-09-17 16:53:14

SQL中CREATE

2010-09-17 14:48:28

SQL條件語句

2010-09-07 11:24:25

SQL語句

2010-09-26 10:08:43

sql條件語句

2010-11-04 11:39:47

2010-09-07 11:33:04

SQL語句

2010-07-08 13:26:02

SQL Server

2010-09-09 16:34:19

SQL循環(huán)while

2010-09-03 10:40:30

SQL刪除

2010-09-14 10:16:57

sql server

2010-09-02 11:47:43

SQL刪除

2010-07-08 13:32:22

SQL Server

2010-11-12 13:08:36

動態(tài)sql語句

2010-10-21 12:16:11

SQL Server查

2010-11-11 11:13:54

SQL Server

2010-10-19 16:06:26

SQL Server索

2010-09-06 13:34:37

Sql Server語句

2010-09-28 14:06:43

Sql Server表

2010-10-22 15:52:41

SQL Server創(chuàng)
點贊
收藏

51CTO技術(shù)棧公眾號