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.