MySQL--1 Database and table operations

Source: Internet
Author: User

1. Database Operation

#创建数据库
Create database name Charset=utf8;

#删除数据库
drop database name;

#切换数据库/Use Database
Use database name;

#查看当前选择的数据库
Select Database ();

#查看所有数据库
show databases;

2. Table operation
#查看当前数据库中所有表
Show tables;

#创建表
Auto_increment indicates auto-grow

CREATE TABLE table name (column and type);
Such as:
CREATE TABLE Students (
ID int auto_increment PRIMARY key,
Name varchar (ten) is not NULL,
Birthday datetime,
Gender bit default 1,
Isdelete bit default 0
);
#修改表
ALTER TABLE table name add|change|drop column name type;
Such as:
#增加列
ALTER TABLE students add hometown varchar (a) not null;
#修改列名
ALTER TABLE students change hometown Tel Int (one) not null;
#删除列
ALTER TABLE students DROP TEL;

MySQL--1 Database and table operations

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.