The CREATE TABLE [if not EXISTS] table name (
field 1 data type [constraint or index list],
field 2 data type [constraint or index list]
)
[List of table options];
#虚拟表的概念: Manipulate the results of a query (a table) as a table
#讲虚拟表保存起来 (put in a variable) that's the view .
#创建用于登录的表
drop table if exists login; If it exists, remove the new
CREATE TABLE Login (
userid varchar (s) NOT null primary key comment ' This is the account number ',
password varchar () Not NULL comment ' This is the password ',
username varchar (Ten) Comment ' username ',
sex int (1) Default 1 comment ' 0 for female, 1 for male '
);
drop table if not exists login; If it exists, it's not built.
CREATE TABLE Login (
userid varchar (s) NOT null primary key comment ' This is the account number ',
password varchar () Not NULL comment ' This is the password ',
username varchar (Ten) Comment ' username ',
sex int (1) Default 1 comment ' 0 for female, 1 for male '
);
MySQL command
#查看有那些数据库
show databases;
#数据库的相关操作
#创建数据库
CREATE Database test110 charset UTF8;
#删除数据库
drop database test110;
#修改数据库
ALTER DATABASE test110 character Set=utf8;
#必须先进入库 Execute the following command
#只要不执行这两个命令就会一直在这个库中
#show databases; use other databases;
#创建表
CREATE table www (
ID int,
name varchar (a)
);
#查看表 empty;
show tables;
#删除表
drop table www;
#查看表结构 desc table name; primary KEY
desc www;
4-20 MySQL collation (build table statement and MySQL command)