Tornado 学习 -- 数据库(一)

sql 文件使用命令:

   mysql -uroot -p < XX.sql

sql命令:

show create table xxx --显示创建这个表的时候的语句

创建数据库:

create database xf default character set utf8;

使用数据库:

use xf;

创建表:

create table xf_user_info(

    ui_user_id bigint auto_increment comment  ‘用户ID’,
    ui_name varchar(64)  not null comment '用户名',
    ui_passwd varchar(128) not null commnet '密码',
    ui_age int null comment '年龄',
    ui_mobile char(11) not null comment '电话号码',
    ui_avatar varchar(128)  null comment '头像',
    ui_ctime datetime not null default current_timestamp comment '创建时间',
    ui_utime datetime not null default current_timestamp on update current_timestamp  comment '更新时间',
    primary key (ui_user_id),
    unique (ui_mobile),    
) engine=InnoDB default charset=utf8 comment '用户表'

engine=InnoDB --指定数据库引擎

删除数据库:

drop database xf

联合查询 --优先使用联合查询:

inner join 内连接: 查询交集  select * from A inner join B on a.aid = b.bid

left join 左连接: 左边的表数据全部保留   select * from A left join B on a.aid = b.bid

right join 右连接: 右边的表数据全部保留   select * from A right join B on a.aid = b.bid

outer  join 外连接: 查询并集,并去重   select * from A outer  join B on a.aid = b.bid

 

truncate table xxx --删除整张表,不删除表结构

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值