MySQL basics-create databases and tables, mysql Databases

Source: Internet
Author: User

MySQL basics-create databases and tables, mysql Databases

MySQL basics-creating databases and tables

Show database overview show databases; (SQL commands are case insensitive)

Mysql> show databases;

Database

Information_schema

Mysql

Test

Summary: The information_schema database, also known as the information architecture, manages the composition information of the database starting from the table and the retrieval of user management information. Confirm the content of these databases to know the status of the current database. You cannot store frequently used data in mysql and information_shema databases. The test database is used for testing. when mysql is installed, the test database is automatically created. The database itself is empty.



Mysql creates A table in database B that is the same as that in database.

Create table B. test as select * from A. test; -------------- structure, the data content is consistent, but the index and foreign key are not copied
So there are two steps:
1: create table B. test like A. test; ------- copy the table structure
2: insert into B. test select * from A. test; ---------- copy data

How can I create a table in a MYsql database?

Create database cookbook; CREATE a DATABASE named "cookbook"

USE cookbook; USE the cookbook Database
Create table limbs (thing VARCHAR (20), legs INT, arms INT); CREATE a TABLE "limbs", which includes the thing, legs, and aems fields.
The command for creating a TABLE is the name of the create table.
The following content is the attribute of fields in the table.

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.