MySQL sample sqls

Source: Internet
Author: User

1) show databases;

2) use dB; enter the database

3) select database (); -- displays the current database

4) Select "consstr" as colname, T. * From tablename T;

5) Select. ID,. valuea, Case (B. valueb is null) when 1 then 'Z' else B. valueb end from tablea as a left join tableb as B on (ID );

6) import the. SQL script:

In the command line: mysql-H ***-u ***-P <***. SQL

Go to MySQL and go to MySQL> command line: Source **. SQL

7) in MySQL, you can arrange query results in vertical lines. You only need to use \ G instead of the semicolon at the end of the query statement. For example:

Select * from test limit 10 \ G

8) show tables like '% name % ';

9) view the table creation statement: Show create table tablename;

10) delete a primary key: alter table tablename drop primary key;

11) export data:

Select * from table into OUTFILE 'filename'; -- can only be exported on the local machine.

Mysqldump-H host-u user-ppwd database table> File

12) import data:

Load data infile 'filepath' into Table tablename;

Mysqldump...

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.