Basic MySQL operations

Source: Internet
Author: User

Basic MySQL operations

1. view all databases

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || wms                |+--------------------+

The first three are the three databases that come with the database.

Ii. Basic syntax for creating a database

1. create database database_name; // database_name is the name of the DATABASE to be created. It cannot be the same as an existing DATABASE.

For example:

mysql> create database db_test;
2. After the DATABASE is created, you can use the show create database statement to view the DATABASE definition.

For example:

mysql> show create database db_test\G;*************************** 1. row ***************************       Database: db_testCreate Database: CREATE DATABASE `db_test` /*!40100 DEFAULT CHARACTER SET latin1 */

3. Run the show databases command to view all DATABASES:

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || db_test            || mysql              || performance_schema || wms                |+--------------------+

Iii. delete a database

1. Syntax

Drop database database_name; // database_name indicates the name of the DATABASE to be deleted. If the DATABASE does not exist, an error occurred while deleting the DATABASE.

2. Example

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || db_test            || mysql              || performance_schema || wms                |+--------------------+mysql> drop database db_test;Query OK, 0 rows affected (0.05 sec)mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || mysql              || performance_schema || wms                |+--------------------+

3. note: Be cautious when using the drop database Command. When executing this command, MySQL will not provide any reminder and confirmation information. After dropping the DATABASE to delete the DATABASE, all data tables and data stored in the database are also deleted and cannot be recovered.


4. Select the current database
Syntax
USE database_name;

Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If you have better suggestions, please mail to my private mailbox: david.louis.tian@outllook.com

Copyright @: This is my original article. Please mark the source for reprinting. Thank you.

MYsql database operations?

What do you want to do? Not clear

Use the command l prompt to operate the mysql database

Create database newdatabasname;
Use newdatabasname;
Create table newtablename (col1 char,
Col2 integer) engine = 'innodb' chareset utf_gerneral_ci;
Insert into newtable valeus ('', 1 );
Delete from newtable where continationid;
Update newtable
Set col = value
From newtable
Where continationid
;
Select * from newtabale where continationid;
Export
SELECT * into outfile 'data.txt'
Fields terminated ','
FROM newtable
;
Import;
Load data infile '/data.txt'
-> Into table newtable lines starting by "xxx ";

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.