MYSQL entry _ common database commands _ MySQL

Source: Internet
Author: User
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

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.