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.