SQL Database Study Notes and SQL Database Study Notes

Source: Internet
Author: User

SQL Database Study Notes and SQL Database Study Notes

Although learning is slow, you need to learn it step by step.


Study Notes:


1. SQL statements are case insensitive
2. MySQL requires a semicolon;
3. Used commands:
Show databases; // display the number of databases that exist. create database first_lesson; // create a database use first_lesson; // use this database show tables; // display the number of tables describe person; // display the table header content
Insert into person values ("dfd", "d", "1990-1-1", "China"); // insert data
Displays the table content select * from table_name;
Create table mytable (name varchar (20), sex char (1), birth date, address varchar (20 ));
4. varchar (20) can be 0-20 characters long
5. SQL is listed as a unit.
6. Duplicate distinct removal is displayed only once;
7. After where, select * from person where name = 'rocky' as the condition ';
Use of quotation marks

Note that we use single quotes around the condition values in the example.


The and or operators are used to filter records based on more than one condition.

And or operators

And or can combine two OR more conditions in the WHERE substatement.

If both the first AND second conditions are true, the AND operator displays a record.

If either the first condition OR the second condition is true, the OR operator displays a record.


Order by statement

The order by statement is used to sort the result set based on the specified column.

BY default, the order by statement sorts records in ascending ORDER.

If you want to sort records in descending order, you can use the DESC keyword.


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.