第二次作业

一、数据库
1、登陆数据库            
2、创建数据库zoo
3、修改数据库zoo字符集为gbk
4、选择当前数据库为zoo
5、查看创建数据库zoo信息
6、删除数据库zoo


一、数据库(步骤)
1、登陆数据库        mysql -hlocalhost -uadmin -p123456        
2、创建数据库zoo         create database zoo;
3、修改数据库zoo字符集为gbk        alter database zoo default character set gbk;
4、选择当前数据库为zoo        use zoo;
5、查看创建数据库zoo信息        show create database zoo;
6、删除数据库zoo            drop database zoo;
二、创建表
1、创建一个名称为db_system的数据库
2、在该数据库下创建两张表,具体要求如下
            员工表 user
     字段        类型    约束            备注
     id        整形    主键,自增长        id
     NAME        字符型    非空            姓名
     gender         字符    非空            性别
     birthday    日期型                    生日
     entry_date    日期型    非空            入职时间
     job         字符型    非空            职位
-------------------------------user---------------------------
create table user(
     id int primary key auto_increment comment 'id',
     NAME char(20) not null comment '姓名',
     gender char(4) not null comment '性别',
     birthdat date comment '生日',
     entry_date date not null comment '入职时间',
     job char(30) not null comment '职位');
-------------------------------user---------------------------

        员工绩效表 salary
    字段        类型    约束                备注
    id        整形    主键,自增长                id
    userId        字符型    非空,外键,关联的是user表的id字段    用户id
    baseSalary    小数    非空                基本工资
    month        整数    非空                月份
    allowances    小数    非空,默认为0            补贴
------------------------------salary-----------------------------
create table salary(
id int primary key auto_increment comment 'id',
userId int not null comment '用户id',
baseSalary float not null comment '基本工资',
month int not null comment '月份',
allowances float not null default 0 comment '补贴',
foreign key (userId) references user(id) );

------------------------------salary-----------------------------
三、修改表
1、在上面员工表的基本上增加一个image列,类型是blod,长度255。alter table user add column image blob comment'员工照片';
2、修改job列,使其长度为60。   alter table user modify column job varchar(60) comment '职位';
3、删除gender列。        alter table user drop column gender;
4、表名salary改为usersalary。    rename table salary to usersalary;
5、修改表的字符集为utf8;    alter table usersalary convert to character set utf8 collate utf8_general_ci;
6、列名name修改为username        alter table user change name username varchar(255) comment '用户名';


相关推荐

  1. 作业第二

    2024-07-11 01:28:01       27 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 01:28:01       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 01:28:01       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 01:28:01       57 阅读
  4. Python语言-面向对象

    2024-07-11 01:28:01       68 阅读

热门阅读

  1. 二刷算法训练营Day57 | 动态规划(17/17)

    2024-07-11 01:28:01       19 阅读
  2. 自定义业务非受检异常

    2024-07-11 01:28:01       25 阅读
  3. GPT-5 一年半后发布?对此你有何期待?

    2024-07-11 01:28:01       22 阅读
  4. DSC主备归档报错

    2024-07-11 01:28:01       22 阅读
  5. DangerWind-RPC-framework---三、服务端下机

    2024-07-11 01:28:01       20 阅读
  6. spring管理bean源码解析

    2024-07-11 01:28:01       20 阅读
  7. a+=1和a=a+1的区别

    2024-07-11 01:28:01       19 阅读
  8. threadLocal

    2024-07-11 01:28:01       20 阅读
  9. GESP C++ 三级真题(2023年9月)T2 进制判断

    2024-07-11 01:28:01       23 阅读
  10. qt中connect函数的使用方法

    2024-07-11 01:28:01       27 阅读