日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql gender_Mysql第一弹

發布時間:2025/3/8 数据库 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql gender_Mysql第一弹 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、創建數據庫python

create database python charset=utf8;

2、設計班級表結構為id、name、isdelete,編寫創建表的語句

create table classes(

id int unsigned auto_increment primary key not null,

name varchar(10),

isdelete bit default 0);

向班級表中插入數據python1、python2、python3

insert into classes(name) values('python1'),('python2'),('python3');

3、學生表結構設計為:姓名、生日、性別、家鄉,并且學生表與班級表為多對一的關系,寫出創建學生表的語句

這里認為 gender 默認值1是表示男生,isdelete 默認值0表示未刪除

create table students(

id int unsigned auto_increment primary key not null,

name varchar(10) not null,

birthday date,

gender bit default 1,

hometown varchar(20),

clsid int unsigned,

isdelete bit default 0);

4、向學生表中插入數據:這里認為 gender 默認值1是表示男生

? * python1班有郭靖、黃蓉,要求:使用全列插入,一次一值

? * python2班有楊過、小龍女,要求:使用指定列插入,一次一值

? * 未分班的學生有黃藥師、洪七公、洪七婆,要求:使用指定列插入,一次多值

insert into students values(0,'郭靖','2016-1-1',1,'蒙古',1,0);

insert into students values(0,'黃蓉','2016-5-8',0,'桃花島',1,0);

insert into students(name,gender,clsid) values('楊過',1,2);

insert into students(name,clsid) values('小龍女',2);

insert into students(name) values('黃藥師'),('洪七公'),('洪七婆');

5、查詢學生的姓名、生日,如果沒有生日則顯示無

select name,ifnull(birthday,'無') from students;

6、查詢學生的姓名、年齡

select name,year(now()) - year(birthday) as age from students;

7、邏輯刪除洪七婆

update students set isdelete=1 where name='洪七婆'

8、修改洪七公的性別為女(gender為0就是女)

update students set gender=0 where name='洪七公'

9、設計科目表subjects,包括科目名稱

create table subjects(

id int unsigned auto_increment primary key not null,

name varchar(20),

isdelete bit default 0);

10、向表中插入數據,科目名有:python、數據庫、前端

insert into subjects(name) values('python'),('數據庫'),('前端');

11、設計成績表,字段包括:學生id、科目id、成績

create table scores(

id int unsigned auto_increment primary key not null,

score int,

stuid int unsigned,

subid int unsigned);

12、向成績表中添加一些示例數據

insert into scores(score,stuid,subid) values

(100,1,1),(98,1,2),(90,1,3),

(95,2,1),(100,2,2),(98,2,3),

(90,3,1),(80,3,2),(85,3,3),

(70,4,1),(60,4,2),(87,4,3);

總結

以上是生活随笔為你收集整理的mysql gender_Mysql第一弹的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。