MySQL: database knowledge point

Source: Internet
Author: User
I. Terms 1. database 2. database Management System (DBMS) 3. column (row) 4. Primary Key 5. SQL (StructuredQueryLanguage) structured Query Language Features: (1) All DBMS Support (2), easy to learn, flexible and powerful 2. Common commands 6. MySQL options and parameters: 1: Specified

I. Terms 1. database 2. database Management System (DBMS) 3. column/row 4. Primary key) 5. Features of Structured Query Language (1) supported by all DBMS (2), easy to learn, flexible and powerful 2. One of the commonly used commands 6. MySQL options and parameters: 1: Specify

I. Terms

1. database)

2. Database Management System (DBMS)

3. column/row)

4. Primary key)

5. Structured Query Language (Structured Query Language)

Features: (1) All DBMS support

(2) easy to learn, flexible, and powerful

Ii. Common commands

6. MySQL options and parameters:

1: Specify the user login name Ben:

2: mysql-u ben

3: provide the user name, host, port, and password:

4: mysql-u ben-p-h myserver-p 9999

(1) enter the command after mysql> and enter help or/h for help.

(2) run the command; or/g. Enter quit and exit to exit the command line.

7. clause ):

Clause has the meanings of clauses and clauses. An SQL statement consists of clauses, which are optional and required. A clause usually consists of a keyword and provided data. For example, the FROM clause of the SELECT statement, or the order by clause

8. Do not use wildcard characters (*) Because columns that are not required for retrieval may degrade the search or program performance.

9. The DISTINCT keyword indicates that Mysql returns only different values:

1: select distinct title FROM new

10. The LIMIT Clause limits the returned results.

1: SELECT id, title FROM new LIMIT 3

LIMIT m, n: where m indicates starting from m, n indicates the number of rows to be retrieved

If the number of rows is not enough, search for the largest row.

Note: Mysql5 supports another LIMIT substitution syntax. LIMIT n OFFSET m: Start from m To qu n rows.

1: SELECT id, title FROM new LIMIT 1 OFFSET 3

2: SELECT id, title FROM new LIMIT 3, 1

3: Same effect

11. Use a fully qualified table name

1: SELECT new. id, new. title FROM new

2: Of course, the table can also be fully qualified, such as: Mydata. new

12. order by clause

The order by clause extracts the names of one or more columns. Therefore, the output is sorted in ascending ORDER (ASC) BY default and can be sorted in descending ORDER (DESC ), note that DESC applies only to the column names directly located in front of DESC.

If you sort multiple columns in descending order, you must specify the DESC keyword in each column.

13. Use the SHOW statement to find out the current database on the server.

1: show databases;

Followed by a plural number

14. Create a database named MYSQLDATA

1: create database mysqldata;

15. Create a database table

1: create table product (pro_id INT, pro_price FLOAT, pro_name VARCHAR (20 ));

17. display table structure

1: DESCRIBE product

Describe: Description and description

The following information is displayed in navicat for Mysql:

18. Add records to the table

1: insert into product VALUES (15.00, 'pen ')

2: # insert multiple rows

3: insert into product (pro_price, pro_name) VALUES (12.00, 'toothpaste '),

4: (18.00, 'belt'), (15.00, 'basin'), (52.30, 'pot ')

19. Create an id in navcat for mysql

20. Set character sets in navcat for mysql

Select 'product' table --- Right-click 'Design table '---

You can also set the primary key.

In this way, we can insert Chinese data into the table ;:

1: insert into product (pro_price, pro_name) VALUES (1.00, 'softdrink '), (2.00, 'Mineral water ')

21. delete a table

1: mysql> drop table mytable;

22. Clear the table

1: delete from new

23. Update Data

1: UPDATE product SET pro_price = 50.00 WHERE pro_name = 'pot'

24. Use the combination of order by and LIMIT to find the highest or lowest value in a column:

1: SELECT pro_price, pro_name FROM product order by pro_price desc limit 1

Attention Sequence

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.