SQL:找不到数据类型Schedule_type

时间:2018-05-26 19:51:51

标签: sql sql-server

我收到了一个错误,我已经面临这样的错误了几天。我在互联网上尝试了各种各样的搜索,但是徒劳无功。

这是我的SQL代码:

Create table Section 
(
    id_section int not null, 
    namesection varchar(25) not null,
    Primary Key (id_section),
    description varchar(100)
);

Insert into Section (id_section, namesection, description) 
values (1, 'Women', 'Clothes for women'),
       (2, 'Men', 'Clothes for men'),
       (3, 'Children', 'Clothes for children');

Create table Product
(
    id_product int not null,
    nameproduct varchar(25) not null, 
    price int not null, 
    id_section int,
    Primary key (id_product),
    constraint fk_section 
         foreign key (id_section) references Section (id_section)
);

Insert into Product (id_product, nameproduct, price, id_section) 
values (1, 'T-shirt blue', 15, 1),
       (2, 'Skirt- red', 30, 1),
       (3, 'Dress black', 50, 1),
       (4, 'Shirt', 45, 2),
       (5, 'T-shirt white', 15, 2),
       (6, 'Pants', 25, 2),
       (7, 'T-shirt black', 15, 3),
       (8, 'Pants', 25, 3);

select *
from Product;

alter table Product drop price;

Create table Showcase 
(
    id_showcase int not null,
    description varchar(200),
    capacity int,
    Primary key(id_showcase),
    id_product int,
    constraint fk_product 
        foreign key (id_product) references Product (id_product)
);

Insert into Showcase (id_showcase, description, id_product ) 
values(1,'women of showcase', 1);
                    Insert into Showcase (id_showcase, description, id_product ) values(2,'women of showcase', 2);
                    Insert into Showcase (id_showcase, description, id_product ) values(3,'women of showcase', 1);
                    Insert into Showcase (id_showcase, description, id_product ) values(4,'women of showcase', 2);
                    Insert into Showcase(id_showcase, description, id_product ) values(5,'men of showcase', 3);
                    Insert into Showcase(id_showcase, description, id_product ) values(6,'men of showcase', 3);
                    Insert into Showcase(id_showcase, description, id_product ) values(7,'men of showcase', 4);
                    Insert into Showcase(id_showcase, description, id_product ) values(8,'children of showcase', 5);
                    Insert into Showcase(id_showcase, description, id_product ) values(9,'children of showcase', 6);
                    Insert into Showcase(id_showcase, description, id_product ) values(10,'children of showcase', 5);
                    Insert into Showcase(id_showcase, description, id_product ) values(11,'children of showcase', 6);

Create table Warehouse(
                    id_warehouse int not null,
                    description varchar(200),
                    Primary Key(id_warehouse),
                    id_product int,
                    foreign key (id_product) references Product (id_product));

                    Insert into Warehouse (id_warehouse, description, id_product ) values(1,'women of showcase', 1);
                    Insert into Warehouse (id_warehouse, description, id_product ) values(2,'men of showcase', 4);
                    Insert into Warehouse (id_warehouse, description, id_product ) values(3,'children of showcase', 6);


Create Type Schedule_type as table(
                    [description] varchar(100), IsBlocked Bit) ;


Create table Employee (
                    id_employee int not null,
                    employeename varchar(25) not null,
                    address varchar(20) not null,
                    email  varchar(20) not null,
                    phone varchar(9) not null,
                    schedule  Schedule_type,
                    Primary Key (id_employee)
                    );

Create table Schedule(
                    id_schedule int not null,
                    description varchar(100)
                    Primary key (id_schedule))
                    ;

        Insert into Schedule(id_schedule, description) values(1, 'Day Shift');
            Insert into Schedule(id_schedule, description) values(2, 'Night Shift');

                select * from Schedule ;
                drop table Schedule;
                alter table Employee drop id_schedule;

Create table Employee (
                    id_employee int not null,
                    employeename varchar(25) not null,
                    address varchar(30) not null,
                    email  varchar(20) not null,
                    phone varchar(9) not null,
                    Primary Key (id_employee),
                    id_schedule int,
                    foreign key(id_schedule) references Schedule (id_schedule));

            Insert into Employee(id_employee, employeename, address, email, phone,id_schedule) values(1, 'Grumet Alina', 'bl.Unirii 1B','gr.alina@gmail.com','069888555',1);
            Insert into Employee(id_employee, employeename, address, email, phone,id_schedule) values(2, 'Stefan Sabin', 'str.Alex.Makedonski','str.sab@gmail.com','085588555',1);
            Insert into Employee(id_employee, employeename, address, email, phone,id_schedule) values(3, 'Dimitrescu Alex', 'Liverpool str.1c','sim.alexa@gmail.com','45885585',1);
            Insert into Employee(id_employee, employeename, address, email, phone,id_schedule) values(4, 'Gori Eva', 'Bucharest str.24','gr.eva@gmail.com','85885885',1);
            Insert into Employee(id_employee, employeename, address, email, phone,id_schedule) values(5, 'Istrate Maria', 'sectorul1','ist.mar@gmail.com','555584751',2);
            Insert into Employee(id_employee, employeename, address, email, phone,id_schedule) values(6, 'Georghiu Alina', 'Ilfov','geor.and@gmail.com','069585585',2);
            Insert into Employee(id_employee, employeename, address, email, phone,id_schedule) values(7, 'Gonta Mihaela', 'lozova','gont.mih@gmail.com','258968589',2);

Create table Sale (
                id_sale int not null,
                cod_bar int not null,
                sale_nr varchar(4) not null,
                Primary Key (id_sale),
                id_employee int,
                foreign key(id_employee) references Employee(id_employee));

                Insert into Sale (id_sale, cod_bar, sale_nr,id_employee ) values(1,123456,'123',1);
                Insert into Sale (id_sale, cod_bar, sale_nr,id_employee ) values(2,789654,'n53',2);
                Insert into Sale (id_sale, cod_bar, sale_nr,id_employee ) values(3,177456,'12',3);
                Insert into Sale (id_sale, cod_bar, sale_nr,id_employee ) values(4,122366,'23',4);
                Insert into Sale (id_sale, cod_bar, sale_nr,id_employee ) values(5,123556,'89',5);
                Insert into Sale (id_sale, cod_bar, sale_nr,id_employee ) values(6,369852,'1mn',6);

                drop table Sale;

                Select* from Sale;
Create table Product_Sale(
                id_product_sale int not null,
                Primary Key (id_product_sale),
                id_sale int,
                foreign key(id_sale) references Sale(id_sale),
                id_product int,
                foreign key(id_product) references Product(id_product));

                Insert into Product_Sale (id_product_sale, id_sale, id_product) values(1,1,1);
                Insert into Product_Sale (id_product_sale, id_sale, id_product) values(2,2,3);
                Insert into Product_Sale (id_product_sale, id_sale, id_product) values(3,3,2);
                Insert into Product_Sale (id_product_sale, id_sale, id_product) values(4,5,4);
                Insert into Product_Sale (id_product_sale, id_sale, id_product) values(5,4,6);

                Select* from Product_Sale;
                drop table Product;



    --          drop database Project;`enter code here`

这就是错误:

  

列,参数或变量#6:找不到数据类型   时间安排:SCHEDULE_TYPE。

所以问题是当我创建表类型Schedule_type之后,我想在另一个表中使用它(在employee表中)它说没有。

0 个答案:

没有答案