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 ";