2个回答
展开全部
举例:学生成绩数据库
1.创建一个数据库:
CREATE DATABASE XSCJ
ON
(NAME='XSCJ_DATA',
FILENAME='D:\Program Files\Microsoft SQL Server\MSSQL\Data\XSCJ_DATA.MDF',
SIZE=5MB,
MAXSIZE=50MB,
FILEGROWTH=10%
)
LOG ON
(NAME='XSCJ_LOG',
FILENAME='D:\Program Files\Microsoft SQL Server\MSSQL\Data\XSCJ_LOG.LOG',
SIZE=2MB,
MAXSIZE=5MB,
FILEGROWTH=1MB
)
GO
2.创建学生信息表:
CREATE TABLE XS
(学号 CHAR(6) PRIMARY KEY,
姓名 CHAR(6) NOT NULL,
专业名 CHAR(10) NULL,
性别 BIT NOT NULL,
出生时间 DATETIME NOT NULL,
总学分 TINYINT NOT NULL,
备注 TEXT NULL
)
GO
3.向XS表中插入数据:
INSERT INTO XS
VALUES('001106','李方方','计算机',1,'1980-11-20',50,NULL)
GO
INSERT INTO XS
VALUES('001107','李明','计算机',1,'1980-05-01',54,'提前修完《数据结构》,并获得学分')
GO
INSERT INTO XS
VALUES('001108','林一帆','计算机',1,'1979-08-05',52,'已提前修完1门课')
GO
4.查询XS表:
SELECT *
FROM XS
5.修改学号为001106同学的专业:
UPDATE XS
SET 专业名='通信工程'
WHERE 学号='001106'
GO
6.删除李方方同学的信息:
DELETE FROM XS
WHERE 姓名='李方方'
GO
1.创建一个数据库:
CREATE DATABASE XSCJ
ON
(NAME='XSCJ_DATA',
FILENAME='D:\Program Files\Microsoft SQL Server\MSSQL\Data\XSCJ_DATA.MDF',
SIZE=5MB,
MAXSIZE=50MB,
FILEGROWTH=10%
)
LOG ON
(NAME='XSCJ_LOG',
FILENAME='D:\Program Files\Microsoft SQL Server\MSSQL\Data\XSCJ_LOG.LOG',
SIZE=2MB,
MAXSIZE=5MB,
FILEGROWTH=1MB
)
GO
2.创建学生信息表:
CREATE TABLE XS
(学号 CHAR(6) PRIMARY KEY,
姓名 CHAR(6) NOT NULL,
专业名 CHAR(10) NULL,
性别 BIT NOT NULL,
出生时间 DATETIME NOT NULL,
总学分 TINYINT NOT NULL,
备注 TEXT NULL
)
GO
3.向XS表中插入数据:
INSERT INTO XS
VALUES('001106','李方方','计算机',1,'1980-11-20',50,NULL)
GO
INSERT INTO XS
VALUES('001107','李明','计算机',1,'1980-05-01',54,'提前修完《数据结构》,并获得学分')
GO
INSERT INTO XS
VALUES('001108','林一帆','计算机',1,'1979-08-05',52,'已提前修完1门课')
GO
4.查询XS表:
SELECT *
FROM XS
5.修改学号为001106同学的专业:
UPDATE XS
SET 专业名='通信工程'
WHERE 学号='001106'
GO
6.删除李方方同学的信息:
DELETE FROM XS
WHERE 姓名='李方方'
GO
展开全部
创建库:CREATE DATABASE DB_NAME
创建表:CREATE TABLE TABLE_NAME(字段名,字段名....)
查询:SELECT * FROM TABLE_NAME WHERE (条件)
插入:INSERT INTO TABLE_NAME VALUES(值,值...)
修改:UPDATE TABLE TALBE_NAME
SET 字段名 = VALUES
WHERE (条件)
删除:DELETE FROM TALBE_NAME WHERE (条件)
创建表:CREATE TABLE TABLE_NAME(字段名,字段名....)
查询:SELECT * FROM TABLE_NAME WHERE (条件)
插入:INSERT INTO TABLE_NAME VALUES(值,值...)
修改:UPDATE TABLE TALBE_NAME
SET 字段名 = VALUES
WHERE (条件)
删除:DELETE FROM TALBE_NAME WHERE (条件)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询