使用mysql创建数据库实例
2012-08-16 16:46
796 查看
create database mugua charset utf8;
创建数据库
use mugua;
使用该数据库
create table goods (
goods_id int primary key auto_increment,
cat_id smallint not null default 0,
goods_sn char(15) not null default '',
goods_name varchar(30) not null default '',
click_count mediumint unsigned not null default 0,
brand_id smallint not null default 0,
goods_number smallint not null default 0,
market_price decimal(7,2) not null default 0.00,
shop_price decimal(7,2) not null default 0.00,
add_time int unsigned not null default 0
)charset utf8;
创建一张goods表
insert into mugua.goods
select
goods_id,cat_id,goods_sn,goods_name,click_count,brand_id,goods_number,
market_price,shop_price,add_time
from ecshop.ecs_goods;
// 将数据从一个库中的表导到另一个库中的表
create table category (
cat_id smallint primary key auto_increment,
cat_name varchar(30) not null default '',
parent_id smallint not null default 0
)charset utf8;
创建一张category表
insert into mugua.category
select
cat_id,cat_name,parent_id
from ecshop.ecs_category;
// 将数据从一个库中的表导到另一个库中的表
create table brand (
brand_id smallint primary key auto_increment,
brand_name varchar(30) not null default ''
)charset utf8;
创建一张brand表
insert into mugua.brand
select
brand_id,brand_name
from ecshop.ecs_brand;
// 将数据从一个库中的表导到另一个库中的表
建立一张表和另一张表的结构一样:create table g2 like goods;
清空一张表:truncate g2;
列理解成变量 可以计算
取出的结构可以理解成一张临时的表
创建数据库
use mugua;
使用该数据库
create table goods (
goods_id int primary key auto_increment,
cat_id smallint not null default 0,
goods_sn char(15) not null default '',
goods_name varchar(30) not null default '',
click_count mediumint unsigned not null default 0,
brand_id smallint not null default 0,
goods_number smallint not null default 0,
market_price decimal(7,2) not null default 0.00,
shop_price decimal(7,2) not null default 0.00,
add_time int unsigned not null default 0
)charset utf8;
创建一张goods表
insert into mugua.goods
select
goods_id,cat_id,goods_sn,goods_name,click_count,brand_id,goods_number,
market_price,shop_price,add_time
from ecshop.ecs_goods;
// 将数据从一个库中的表导到另一个库中的表
create table category (
cat_id smallint primary key auto_increment,
cat_name varchar(30) not null default '',
parent_id smallint not null default 0
)charset utf8;
创建一张category表
insert into mugua.category
select
cat_id,cat_name,parent_id
from ecshop.ecs_category;
// 将数据从一个库中的表导到另一个库中的表
create table brand (
brand_id smallint primary key auto_increment,
brand_name varchar(30) not null default ''
)charset utf8;
创建一张brand表
insert into mugua.brand
select
brand_id,brand_name
from ecshop.ecs_brand;
// 将数据从一个库中的表导到另一个库中的表
建立一张表和另一张表的结构一样:create table g2 like goods;
清空一张表:truncate g2;
列理解成变量 可以计算
取出的结构可以理解成一张临时的表
相关文章推荐
- mysql使用-创建数据库及表格
- mysql创建数据库,创建数据库表导入xlsx、txt文本,查询、删除、插入数据语句的使用
- Qt中MySQL的使用实例以及数据库遍历
- 安装完Oracle后 使用dbca创建数据库 弹出ORA-01092: ORACLE 实例终止,强制断开连接
- Navicat for MySQL使用手记(上)--创建数据库和表 推荐
- 使用JMeter创建数据库(Mysql)测试
- MySQL5.7 + Workbench的安装和创建数据库以及表等简单使用
- mysql 使用 PHP脚本创建数据库
- php+mysqli使用面向对象方式查询数据库实例
- 使用 MySQL 数据库创建简单的 JSP 应用程序(1)
- Navicat for MySQL使用手记(上)--创建数据库和表
- MYSQL添加新用户 MYSQL为用户创建数据库 MYSQL为新用户分配权限 无法使用新增的用户登陆mysql
- 基于CentOS的MySQL学习补充三--使用Shell批量创建数据库表
- Navicat for MySQL使用手记(上)--创建数据库和表
- MYSQL的创建新用户数据库的步骤实例
- 使用 MySQL 数据库创建简单的 JSP 应用程序(2)
- 使用JMeter创建数据库(Mysql)测试
- MySQL 参考手册 3.3创建使用数据库
- mysql 数据库Event定时任务使用详解(Navicat 及直接SQL语句创建)
- 【MySQL 05】使用Java对MySQL进行操作(创建数据库)