建“学生”Student表
create table Student
(
Sno int not null primary key,
Sname varchar(20) null,
Ssex char(2) null,
Sage int null,
Sdept varchar(20) null
)
go
a) 查询全体学生的详细记录
select * from Student
b) 查询年龄在20至23岁之间的学生的姓名、系别、和年龄
select Sname,Sdept,Sage from Student where Sage between 20 and 23
上面就是你要的答案.还不会的可以加我的QQ:171863768
if exists (select 1
from sysobjects
where id = object_id('Student')
and type = 'U')
drop table Student
go
/*==============================================================*/
/* Table: Student */
/*==============================================================*/
create table Student (
Sno number not null,
Sname varchar2(20) null,
Ssex number null,
Sage number null,
Sdept number null,
constraint PK_STUDENT primary key (Sno)
)
go
a) select * from Student ;
b) select t.sname,t.sdept,t.sage from Student t where t.sage between 20 and 23
建表
CREATE TABLE [dbo].[Student] (
[Sno] [varchar] (50) NOT NULL ,
[Sname] [varchar] (50) NULL ,
[Ssex] [varchar] (5) NULL ,
[Sage] [int] NULL ,
[Sdept] [varchar] (50) NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Student] WITH NOCHECK ADD
CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED
(
[Sno]
) ON [PRIMARY]
1.select * from Student
2.select Sname,Ssex,Sage
from student
where Sage>=20 and Sage<=23
1
CREATE VIEW CA_authors(au_lname,au_fname,phone,city) AS
select au_lname,au_fname,phone,city from authors
2
select Firstname,Lastname from Employees
where right(left(Firstname,2),1)='A'
3
CREATE TABLE Student (
Sno varchar(10) PRIMARY KEY,
Sname varchar(10),
Ssex varchar(10),
Sage varchar(10),
Sdept varchar(10))
a
select * from Student
b
select Sname,Sdept,Sage from Student where Sage between '20' and '23'
create table [Student]
( [Sno] [int] NOT NULL PRIMARY KEY,
[Sname] [varchar](50),
[Ssex] [char](1),
[Sage] [int],
[Sdept] [varchar](50)
)
a)select * from [Student]
b)select [Sname],[Sdept],[Sage] from [Student] where [Sage] BETWEEN 20 AND 23