一、 什么是数据库?为什么使用数据库? 1, 存储数据系统 2, 持久存储,快速查询,多人共享,安全可控,减少冗余 二、 实操题。用命令的方式新建一个学生信息表。数据库名为xuesheng。表名为xuesheng_user。表中的字段为 id ,username , phone , address ,age。其中id类型为int设置为主键,自增,不能为空的约束条件,username、address为字符串设置不能为空的约束条件。Phone设置为int设置不能为空的约束条件。Age设置为int 不能为空的条件。(命令截图) create database xuesheng; create table xuesheng_user(id int PRIMARYKEY auto_increment not null,username varchar(255) not null,phone int notnull,address varchar(255) not null,age int not null) 三、 基于上面的数据库,新增一个int类型chengji的字段设置不能为空的约束条件。然后在表中插入以下数据 Username = 张三 phone = 13888888888 address= 福建 age = 18 chengji = 0 (步骤命令截图) alter table xuesheng_user add columnchengji int not null DEFAULT 0 insert intoxuesheng_user(username,phone,address,age,chengji) values ("张三","1388888888","福建",18,0)
|