mysql 习题
习题1
1、创建一个库(dt55_mysql),在库下创建一张students表
(1)students表中的字段有:id(int类型),stuName(varchar类型),age(int类型),weight(体重,float类型)
(2)往students包中同时插入3条数据
(3)查询students表,为每个字段取一个别名:id(主键)、stuName(学生名字),age(年龄),weight(体重)
1 CREATE DATABASE dt55_mysql CHARACTER SET utf8; 2 CREATE TABLE students( 3 id INT, 4 stuName VARCHAR(32), 5 age INT, 6 weight FLOAT 7 ); 8 9 INSERT INTO students VALUES (1, 'wang1', 18, 50 ),(2, 'wang2', 18, 50 ), 10 (3, 'wang3', 18, 50 ); 11 12 SELECT id AS 主键 ,stuName AS 学生名字, age AS 年龄, weight AS 体重 FROM students;
习题2
create database guan CHARACTER set utf8; use guan; create table Book(B_ID int,B_NAME varchar(20),P_ID INT,B_AUTHOR varchar(20),B_PRICE float); desc table Book; alter table Book change B_ID id int; alter table Book change B_NAME bookname; alter table Book change B_NAME bookname varchar(20); alter table Book drop P_ID; alter table Book change bookname bookname varchar(40);