增: create database db1 default charset=utf8; 删: drop database db1; 改: alter database db1 charset utf8 查: show databases; 查看全部的数据库 show create database db1; 查看指定的数据库
设置默认的utf8,在配置文件中:写上character_set_server = utf8
use db2 #表明你鼠标双击切换目录
select database() #查看你当前在哪一个文件夹
能够由字母、数字、下划线、@、#、$ 区分大小写 惟一性 不能使用关键字如 create select 不能单独使用数字 最长128位
show tables;
create table 表名称( 字段1 类型(长度) 约束, 字段2 类型(长度) 约束, ...... ) [指定字符集];
建立帐户表,包含帐号、户名字段数据库
create table acct( acc_num varchar(32), -- 帐号 acct_name varchar(128) -- 户名 ) default charset=utf8; -- 指定字符集
查看表结构:
desc 表名
查看建表语句:
show create table 表名
drop table 表名
删除acct表函数
drop table acct;
create table acct_new select * from acct;
(只复制知足查询条件数据)spa
create table acct_new select * from acct where balance<2000;
(没有知足条件数据)code
create table acct_new select * from acct where 1=0;
注意:该方式复制表,不会复制键的属性server
alter table 原表名 rename to 新表名
alter table acct rename to acct_new;