資料庫練習題

2021-09-17 05:02:21 字數 1204 閱讀 5205

1:檢視原始資料庫information_schema中的表,並顯示出views表的字段結構屬性資訊

show databases;

use information_schema;

desc views;

2:建立乙個offcn資料庫,並建立乙個students表,欄位為id,name,age,phone,height

create database offcn;

use offcn;

create table students (id int,name varchar(4),age varchar(3),plane varchar(11),height varchar(3))

3:檢視students表的表結構

desc students;

4:在上題建立的students表中,隨意插入5條資料

insert into students values(1,『ls』,『12』,『12341234123』,『123』),(2,『zs』,『13』,『122345123451』,『124』),(3,『ww』,『15』,『12345612345』,『125』)(4,『zp』,『16』,『12345671234』,『126』),(5,『eg』,『17』,『12345678123』,『127』);

5:查詢所有建立的資料

select * from students;

6:將students表名修改為students_details

alter table students rename to students_details;

7:將students_details中height欄位刪除

alter table students_details drop height;

8:在students_details裡新增乙個新字段,欄位名為***,並增加兩條資料。

alter table students_details add *** varchar(5);

update students_details set ***=』man』 where id=2;

update students_details set ***=』man』 where id=4;

9:刪除students_details表

drop table students_details;

10:刪除offcn資料庫

drop database offcn;

資料庫練習題

一 設有一資料庫,包括四個表 學生表 student 課程表 course 成績表 score 以及教師資訊表 teacher 四個表的結構分別如表1 1的表 一 表 四 所示,資料如表1 2的表 一 表 四 所示。用sql語句建立四個表並完成相關題目。表1 1資料庫的表結構 表 一 student...

資料庫練習題一

有關聯式資料庫 職工關係 employee 職工號eno,職工名ename 工作關係 works 職工號eno,公司號cno,工資wage 公司關係 company 公司號cno,公司名cname 假設職工可以在多個公司兼職,請用關係代數表示式寫出至少在公司號為 c2 和 c5 公司兼職的職工名。1...

資料庫練習題5

1 事務的原子性是指 a 事務中包括的所有操作要麼都做,要麼都不做 b 事務一旦提交,對資料庫的改變是永久的 c 乙個事務內部的操作及使用的資料對併發的其他事務是隔離的 d 事務必須是使資料庫從乙個一致性狀態變到另乙個一致性狀態 2 事務的一致性是指 a 事務中包括的所有操作要麼都做,要麼都不做 b...