MYSQL _ common database commands bitsCN.com
MYSQL _ common database commands
1. log on
$ Mysql -- user = root -- password = xxxxxx
2. database operations
List all databases
Mysql> show databases;
Create a database
Mysql> create database x123;
Delete database
Mysql> drop database x123;
Connect to the database
Mysql> use x123;
3. Data table operations
Show data tables
Mysql> show tables;
Create a data table
Mysql> create table mytable (name VARCHAR (20), sex CHAR (1), birth DATE );
Display table header
Mysql> describe mytable;
Insert data to a table
Mysql> insert into mytable values ('xieyan ', 'F', '2017-01-01 ');
Search for specific conditions
Mysql> select * from mytable where sex = "f ";
Fuzzy search
Mysql> select * from mytable where name like "% xie % ";
Delete a data table
Mysql> drop table mytable;
Reads and inserts data from a TXT file. SAE does not support the load data command.
(TXT file format: fields are separated by spaces, and records are separated by line breaks)
Mysql> load data local infile "testme.txt" into table mytable;
BitsCN.com