Simple operation guide for MySQL database basics

Source: Internet
Author: User

Recently in the study of MySQL, this article is to do about the MySQL study notes, share with you, hope to learn MySQL knowledge for everyone to help. MySQL is now almost the mainstream database for website construction, and many PHP Web systems use MySQL database. The biggest advantage over MSSQL is open source, free. We hope to make progress together with you.

A simple guide to MySQL Database basics: First enter mysql:mysql-u root-p

1. Build the Library:

Create database name;

For example: Create database MyData; (creating a library called "MyData");

2. Build a table:

Use the name of the library on which to save the table;

CREATE TABLE table name (field set list);

For example: Use MyData; Enter the MyData library

CREATE TABLE MyTable (num VARCHAR), name Varcar (a), birth date,sex CHAR (1)); Create a table named MyTable that contains the school number, name, birthday, and gender.

3. Show all databases:

show databases;

4. Show all tables under a library

Use to query the database name;

Show tables;

5. Delete Tables and libraries:

Delete Library: drop database name;

Delete Table: Name of the drop table;

6. Clear the table record:

Delete from table name;

TRUNCATE TABLE name;

7. Display the records in the table:

SELECT * from table name; * indicates that all records in the table are displayed, or that they can be displayed with different keywords

If there are too many records in the table, only the first few lines can be displayed:

SELECT * from table name limit row number;

For example: SELECT * FROM mytable limit 100; Show the first 100 rows in the MyTable table

8. Rename Table A to B:

ALTER TABLE A rename B;

Other basic can use SQL

Simple operation guide for MySQL database basics

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.