一、创建数据库ishop
创建数据库 ishop
create database ishop default charset=utf8;
use ishop;
创建表king
create table king(
id int(11) primary key,
name varchar(50) not null);
查看 商品类型数据表结构
desc king;
创建表joke
create table joke(
id int(11) not null ,
name varchar(50) not null,
madein varchar(50) not null,
type int(11) not null,
inprice int(11) not null,
outprice int(11) default null,
num int (11) not null default ‘100’,
primary key (id),
constraint fk_joke_king foreign key (type) references king (id));
查看表结构
desc king;
添加检查约束
alter table joke add constraint check(num>o);
查看检查约束
SELECT * FROM information_schema.TABLE_CONSTRAINTS
WHERE table_name=‘joke’;
创建客户数据表 queen
CREATE TABLE queen (
id int(11) NOT NULL,
name varchar(50) NOT NULL,
phone varchar(50) NOT NULL,
gender int(11) NOT NULL DEFAULT ‘1’
);
创建主键约束
alter table queen add constraint primary key (id);
添加地址字段
ALTER TABLE queen aDD address varchar(100) NOT NULL;
查看 客户数据表结构
desc queen;
创建订单数据表 order
create table lorder(
id int(11) not null auto_increment,