深圳尚学堂:数据库基础

深圳尚学堂:数据库基础

技术教程gslnedu2025-03-05 11:58:4916A+A-

1、数据库基础:

1)使用 SQL 语句创建学生表 students

字段 : 学号 :s_id 姓名 :s_name 年龄 :age 班级 :class 辅导员 :assistant

(请设计各字段类型与长度)

2)查询学生表中年龄大于 20 的所有学生的学号与姓名

3)删除 0201 班的所有同学

4)查询 0302 班姓李的学生的个数

5)将班编号以’02’开头的所有班级的辅导员修改为‘李四’

答:1)create table students(s_id number(10) primary key,

s_name varchar(30) not null,

age number(3) not null,

class varchar(20) not null,

assistant varchar(30));

2)select s_id,s_name from students where age>20;

3)delete from students where class=’0201’;

4)select count(s_name) from students

where s_name like ‘李%’ and class='0302';

5)update students set assistant='李四' where class like '02%';

2、

向表 a 中添加字段PolicyNo,类型为字符串,长度为 25 位,请写出 SQL;

向表 a 中的PolicyNo 和 StartDate 字段上建立一个索引,请写出 SQL;

答:alter table a add (PolicyNo varchar2(25) );

create index a_index on a(PolicyNo, StartDate);

3、Oracle 数据库和 SQL Server 数据库字串链接操作符号是什么?

答:Oracle 数据库字串连接操作符是 ||,l例如’a’||’b’等价于’ab’

SQL Server 数据库字串链接操作符号是”+”

点击这里复制本文地址 以上内容由朽木教程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

朽木教程网 © All Rights Reserved.  蜀ICP备2024111239号-8