標籤:ar java for 資料 ad ef as 資料庫 sql
drop database if exists STOREDB;
create database STOREDB;
use STOREDB;
create table CUSTOMERS (
ID bigint not null auto_increment primary key,
NAME varchar(16) not null,
AGE INT,
ADDRESS varchar(255)
);
create table ORDERS (
ID bigint not null auto_increment primary key,
ORDER_NUMBER varchar(16) not null,
PRICE FLOAT,
CUSTOMER_ID bigint,
foreign key(CUSTOMER_ID) references CUSTOMERS(ID)
);
insert into CUSTOMERS(ID,NAME,AGE,ADDRESS) values(1, ‘小張‘,23, ‘北京‘);
insert into CUSTOMERS(ID,NAME,AGE,ADDRESS) values(2,‘小紅‘,29, ‘天津‘);
insert into CUSTOMERS(ID,NAME,AGE,ADDRESS) values(3,‘小丁‘,33, ‘山東‘);
insert into ORDERS(ID,ORDER_NUMBER,PRICE,CUSTOMER_ID) values(1, ‘小張_001‘,100.12, 1);
insert into ORDERS(ID,ORDER_NUMBER,PRICE,CUSTOMER_ID) values(2, ‘小張_002‘,200.32, 1);
insert into ORDERS(ID,ORDER_NUMBER,PRICE,CUSTOMER_ID) values(3, ‘小紅_001‘,88.44, 2);
java訪問資料庫的sql