1. 程式人生 > >mysql 電子商城建表參考

mysql 電子商城建表參考


-- 建立資料庫
drop database if exists haoyigou;
create database haoyigou charset utf8;
use haoyigou;

-- 管理員表
drop table if exists hyg_admin;
create table  hyg_admin(
id tinyint unsigned auto_increment key comment 'id',
username varchar(20) not null unique comment '使用者名稱',
password char(32) not null comment '使用者密碼:md5加密',
email varchar(50) not null comment '郵箱地址'
);
-- 新增管理員
insert into hyg_admin values(null,'admin',md5('admin'),'
[email protected]
'); -- 使用者表 drop table if exists hyg_user; create table hyg_user( hyg_id int primary key auto_increment comment '主鍵', hyg_username varchar(20) not null unique comment '使用者名稱必須唯一', hyg_password char(32) not null comment '使用者密碼:md5加密', hyg_email varchar(50) not null comment '郵箱地址' )charset utf8; -- 新增使用者資訊 insert into hyg_user values(null,'admin',md5('admin'),'
[email protected]
'); -- 使用者收貨資訊表 drop table if exists hyg_delivery; create table hyg_delivery( user_id int comment '使用者id', hyg_name varchar(10) comment '收貨人姓名', hyg_phone varchar(11) comment '手機', hyg_postcode char(10) comment '郵政編碼', hyg_addr varchar(30) comment '詳細地址', hyg_time varchar(30) comment '送貨時間' )charset utf8; --測試資料 INSERT INTO `haoyigou`.`hyg_delivery` (`user_id`, `hyg_name`, `hyg_phone`, `hyg_postcode`, `hyg_addr`, `hyg_time`) VALUES ('1', '黃曉明', '15878521654', '525300', '廣東省廣州市天河街道11', '不限'); --商品表 drop table if exists hyg_goods; create table hyg_goods( goods_id int primary key auto_increment comment '主鍵', goods_name varchar(120) comment '商品名稱', cat_id smallint(5) comment '欄目id', brand_id int comment '品牌id', goods_score int comment '可使用積分', goods_sn varchar(60) comment '貨號', goods_number int comment '庫存量', shop_mprice decimal(10,2) comment '市場價格', shop_price decimal(10,2) comment '本店價格', goods_desc text comment '商品詳細描述', add_time int comment '上架時間', ud_time int comment '更新時間', is_delete tinyint(1) comment '是否已刪除', goods_image varchar(255) comment '圖片名稱', goods_thumb varchar(255) comment '縮圖名稱', goods_sthumb varchar(255) comment '小縮圖片名稱', is_best tinyint(1) comment '是否精品', is_new tinyint(1) comment '是否新品', is_hot tinyint(1) comment '是否熱銷', is_promote tinyint(1) comment '低價促銷' )charset utf8; --插入商品資料 INSERT INTO `haoyigou`.`hyg_goods` (`goods_id`, `goods_name`, `cat_id`, `brand_id`, `goods_score`, `goods_sn`, `goods_number`, `shop_mprice`, `shop_price`, `goods_desc`, `add_time`, `ud_time`, `is_delete`, `goods_image`, `goods_thumb`, `goods_sthumb`, `is_best`, `is_new`, `is_hot`, `is_promote`) VALUES (NULL, 'iphone8', '1', '2', '1200', 'hyg_20152612', '11', '9000', '8000', '一步好手機', '12345678', '58495621', '0', '17_P_1241969394354.jpg', '17_thumb_P_1241969394537.jpg', 'small_thumb_P_1241969394537.jpg', '1', '1', '1', '1'); INSERT INTO `haoyigou`.`hyg_goods` (`goods_id`, `goods_name`, `cat_id`, `brand_id`, `goods_score`, `goods_sn`, `goods_number`, `shop_mprice`, `shop_price`, `goods_desc`, `add_time`, `ud_time`, `is_delete`, `goods_image`, `goods_thumb`, `goods_sthumb`, `is_best`, `is_new`, `is_hot`, `is_promote`) VALUES (NULL, 'iphone8', '1', '2', '1200', 'hyg_20152612', '11', '9000', '8000', '強大手機的日常', '12345678', '58495621', '0', '17_P_1241969394354.jpg', '17_thumb_P_1241969394537.jpg', 'small_thumb_P_1241969394537.jpg', '0', '0', '0', '0'); -- 分類表 drop table if exists hyg_category; create table hyg_category( cat_id int primary key auto_increment comment '主鍵', cat_name varchar(30) comment '欄目名稱', parent_id int comment '欄目的父id' )charset utf8; -- 品牌表 drop table if exists hyg_brand; create table hyg_brand( brd_id int primary key auto_increment comment '主鍵', cat_name varchar(30) comment '品牌名稱' )charset utf8; --新增品牌示例 insert into hyg_brand values(null,'諾基亞'),(null,'三星'),(null,'蘋果'); -- 商品圖片表 drop table if exists shop_album; create table shop_album( id int unsigned auto_increment key comment 'id', pid int unsigned not null comment '商品id', albumPath varchar(50) not null comment '圖片路徑', goods_sthumb varchar(255) comment '小縮圖片名稱' ); --使用者留言表 drop table if exists hyg_message; create table hyg_message( message_id int primary key auto_increment comment '自增', user_id int comment '留言使用者的id', goods_id int default '0' comment '所在商品id,0代表網站留言', message_type int comment '留言型別: 留言 投訴 詢問 售後 求購', message_content text comment '留言內容', message_date int comment '留言時間' )charset utf8; --/*---------------------------------*/ --//--- 訂單表已改!! --/*---------------------------------*/ --原訂單表 --drop table if exists hyg_order; --create table hyg_order( --id int primary key auto_increment comment '自增', --order_id int comment '訂單號', --order_time int comment '下單時間', --order_money decimal(10,2) comment '訂單金額', --order_stat tinyint comment '訂單狀態', --order_exp tinyint comment '送貨方式', --order_pay tinyint comment '支付方式', --goods_id int, --order_mes varchar(50) comment '訂單留言' --)charset utf8; --新訂單表 drop table if exists hyg_order; create table hyg_order( id int primary key auto_increment comment '自增', order_id varchar(30) comment '訂單號', user_id int comment '使用者id', order_good text comment '拼湊商品id和數量:1|3-2|1', order_time int comment '下單時間(時間戳)', order_money decimal(10,2) comment '訂單金額', hyg_name varchar(10) comment '收貨人姓名', hyg_phone varchar(11) comment '手機', hyg_postcode char(10) default '' comment '郵政編碼', hyg_addr varchar(30) comment '詳細地址', order_stat tinyint default '1' comment '訂單狀態', order_exp tinyint default '1' comment '送貨方式', order_pay tinyint default '1' comment '支付方式', order_mes varchar(50) default '' comment '訂單留言' )charset utf8; --訂單詳情表(現實情況會用到) --drop table if exists hyg_orderdetail; --create table hyg_orderdetail( --order_id varchar(15) comment '訂單號', --goods_id int comment '商品的id', --sale_num int comment '購買數量' --)charset utf8; --增加訂單測試資料 insert into hyg_order values(null,'hyg_00000001','1','1|3-2|1','20150126','500','小王','15845261547','512515','中國廣東廣州天朗明居',default,default,default,'儘快發貨!'); insert into hyg_order values(null,'hyg_00000002','2','2|1-2|2','20150127','500','小王','15845261547','512515','中國廣東廣州塘東',default,default,default,'期待!'); --/*---------------------------------*/ --//--- 購物車表已改!! --/*---------------------------------*/ --原購物車 --drop table if exists hyg_cart; --create table hyg_cart( --cart_id int primary key auto_increment comment '自增', --goods_id int comment '商品的id', --select_color varchar(20) comment '選中商品的顏色', --sale_num tinyint comment '購買數量', --shop_price tinyint comment '本店購買價格' --)charset utf8; --新購物車 drop table if exists hyg_cart; create table hyg_cart( cart_id int primary key auto_increment comment '自增', u_id int not null comment '買家id', goods_id int comment '商品的id', price_count int comment '金額小計', mprice_count int comment '市場價格小計', sale_num int comment '購買數量' )charset utf8; --增加測試資料 INSERT INTO `haoyigou`.`hyg_cart` VALUES (NULL, '1', '1', '16000','18000','2'); INSERT INTO `haoyigou`.`hyg_cart` VALUES (NULL , '2', '2', '16000','18000','1'); -- 收藏表 create table hyg_college( id int primary key auto_increment comment '主鍵', user_id int comment '使用者id', goods_id int comment '商品id' )charset utf8; alter table hyg_category add cat_sort tinyint default 20 comment '手機分類排序';

相關推薦

mysql 電子商城參考

-- 建立資料庫 drop database if exists haoyigou; create database haoyigou charset utf8; use haoyigou; -- 管理員表 drop table if exists hyg_admin;

MySQL中創指定存儲引擎

bsp rem sam 建表 tab sig incr ron 創建 create table test( id int(10) unsigned not null auto_increment, name varchar(10) character set utf8,

4-20 mysql 整理 (語句和mysql命令)

AC comment 如果 進入 username -s ID alter ase create table [if not exists] 表名( 字段1 數據類型 [約束或索引列表], 字段2 數據類型 [約束或索引列表]) [表選項列表];#虛擬表的概

mysql_參考欄位

建表常用欄位 ID 主健 varchar(36)  或者 bigint 金額 decimal(15,2)  或者用整數 以分為單位   (主要是怕出錯避免精度) RESERVED_FIELD  reserved_field  預留欄位 varch

flask學習:連線mysql資料庫並

1.首先要下載 flask_sqlalchemy 和  flask_mysqldb。 一般在pycharm中可以搜尋到並且下載。如果出現問題,可以百度一下。 2.配置資料庫的相關設定: root:root,前一個是資料庫使用者名稱,後一個是密碼。 #配置資料庫的地址 a

MYSQL和ORACLE之後修改約束

MYSQL:        修改emp表中的empno欄位為主鍵約束和自增 方法1 alter table 表名 change 舊欄位 新欄位 欄位型別 主鍵約束 自增。 alter table emp change empno empno int primary k

mysql只匯出語句

mysqldump --no-data -u username -p* database_name < filename.sql mysqldump --no-data -uroot -p88888888 tidemedia_cms.userinfo >/dat

mysql如何檢視時的註釋

CREATE TABLE `student` ( `id` int(11) AUTO_INCREMENT PRIMARY KEY COMMENT '學好', `name` varchar(32) NOT NULL DEFAULT '' COMMENT '姓名', `sex` tinyint(1) N

參考

 -- Create table create table APPLSYS.FND_USER (   USER_ID                       NUMBER(15) not null,   USER_NAME                     V

(轉)mysql時反引號的作用

navi _id sta gbk ble 擴展 engine bsp div 試用navicat工具查看現網mysql建表語句時,發現表名和字段名都是反引號引起來的 CREATE TABLE `tab_notice_title_tv` ( `i_id` int(11

mysql數據庫實例

create 刪除 存在 database efault int 字段 primary 日期字段 一。實例。 drop database if exists school; //如果存在SCHOOL則刪除create database school; //建立庫SCHOOL

MySQL時,設置時間字段自己主動插入當前時間

mil post div ipp strong ren current spa blog MySQL 創建表時,設置時間字段自己主動插入當前時間 DROP TABLE IF EXISTS `CONTENT`; CREATE TABLE `CONTENT`

MySQL的語句

unique col 服務 add 作用 寫法 表名 desc 約束 1 show variables like ‘character_set_client‘;#查詢字符集 2 show databases;#列出所有的服務器上的數據庫alter 3 create

java 連接mysql數據庫並創

roo not target mysql數據庫 style static har summary sql數據庫 java鏈接mysql數據庫需要驅動包,那麽我們先去下載驅動包http://dev.mysql.com/downloads/connector/j/,驅動包就是一

mysql規範及註意事項

關系數據庫 並發 arc float nod 32bit 字符串 8bit 設計 表設計規範 1.庫名,表名,字段名必須使用小寫字母,“-”分割 ,長度不得超過12字符 , 要見名識意 ; 2.建議使用Innodb存儲引擎 (1)什麽是存儲引擎 不同的技術及配套的相關功

mysql的註意事項

ada ipv 信息 浮點數 sql 效率 統一 2個 針對 1 庫名,表名,字段名必須使用小寫字母,"_"分割。 2 庫名,表名,字段名必須不超過12個字符。 3 庫名,表名,字段名見名識意,建議使用名詞而不是動詞。 4 建議使用InnoDB存儲引擎。( InnoDB:支

Mysql 與查詢

聚焦 null tle ews har title key arch reat -- ID:新聞的唯一標示-- tiltle:新聞的標題-- content:新聞的內容-- created_at:新聞添加的時間-- types:新聞的類型-- image:新聞的縮略圖--

mysql

not 主鍵索引 pre log primary 屬性 最大 meta mysql5 1.刪除表 drop table table_name; //table_name 表名 2.創建表,當標記某個屬性為主鍵的時候,已經創建主鍵索引

三、MySQL模板

eat arch 結束 刪除 表示 pro exist begin 使用   1. 建表模板   SET FOREIGN_KEY_CHECKS=0;  DROP TABLE IF EXISTS `g_test`;  CREATE TABLE `g_test` (   `i

MySQL

efault varchar 數量 char values one time killed 建表 ----數據庫初始化腳本 ---創建數據庫CREATE DATABASE seckill;---使用數據庫use seckill;---創建秒殺庫存表 CREATE TABLE