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 --删除整张表,不删除表结构