4-20 MySQL collation (build table statement and MySQL command)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.