Drop database if exists storedb;
Create Database Storedb;
Use Storedb;
CREATE TABLE CUSTOMERS (
ID bigint NOT NULL auto_increment primary key,
NAME varchar (+) is not NULL,
Age INT,
ADDRESS varchar (255)
);
CREATE TABLE ORDERS (
ID bigint NOT NULL auto_increment primary key,
Order_number varchar (+) NOT NULL,
Price FLOAT,
customer_id bigint,
Foreign KEY (customer_id) references CUSTOMERS (ID)
);
Insert into CUSTOMERS (id,name,age,address) VALUES (1, ' Xiao Zhang ', 23, ' Beijing ');
Insert into CUSTOMERS (id,name,age,address) VALUES (2, ' Little Red ', 29, ' Tianjin ');
Insert into CUSTOMERS (id,name,age,address) VALUES (3, ' xiaoding ', 33, ' Shandong ');
Insert into ORDERS (id,order_number,price,customer_id) VALUES (1, ' Xiao Zhang _001 ', 100.12, 1);
Insert into ORDERS (id,order_number,price,customer_id) VALUES (2, ' Xiao Zhang _002 ', 200.32, 1);
Insert into ORDERS (id,order_number,price,customer_id) VALUES (3, ' Little Red _001 ', 88.44, 2);
SQL for Java Access database