数据库SQL语句练习题

打印 上一主题 下一主题

主题 1007|帖子 1007|积分 3021

一、要求

 新建产物库mydb6_product,新建3张表,表结构如下:
           

二、实现步骤

        1.创建数据库mydb6_product
               创建命令: create database mydb6_product;
               检察创建的数据库,命令:show databases;
          

        2.创建employees表
                创建命令:
                1、首先需要使用数据库作为当前数据库:use mydb6_product; 
                2、创建二维表employees:
                 create table employees(
                    id int primary key,
                    name varchar(50) not null,
                    age int,
                    gender varchar(10) not null default 'unkwon',
                    salary float);
        3.创建orders表
                创建命令:
                1、创建二维表orders:
                create table orders(
                    id int primary key,
                    name varchar(100) not null,
                    price float,
                    quantity int,
                    category varchar(50));
        4、创建invoices表
                创建命令:
                1、创建二维表invoices
                create table invoices(
                     number int primary key auto_increment,
                     order_id int,
                     in_date date,
                     total_amount float,
                     foreign key(order_id) references orders(id),
                     check(total_amount>0) );
三、检察实现情况

        1、检察表
                命令:show tables;
         

        2、检察表结构
                表employees:
        

                表invoices:
        

                表orders:
        


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

吴旭华

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表