about MySQL
A database is a container for storing organized data.
The database management system DBMS is the software that operates the database.
A table is a structured file that can be used to store specific types of data. Table names in the same database are unique.
A column is a field in a table, and each table is made up of multiple columns. Each column stores a specific type of information, such as employee ID, name, contact, and so on.
The data for each column in the data type (datatype) table has the same data type, which restricts the data type that is stored in the column.
rows (row) are also known as records, and horizontal rows in a table.
primary key (primary key), a column in a table whose value uniquely distinguishes each row in a table. For example, the ID of the employee, the ID of the commodity order. The primary key value is not allowed to be a null value.
SQL(Structured query Language) Structured Query language that is specifically designed to communicate with the database.
Working with databases
- Connect to Native Database: command line input mysql -u root -p , then enter the password
- Display database: Show DATABASES; , select database: Use simpledb; , display table: Show TABLES; Show table column: Show Column S from customers;
Retrieving data
- To retrieve a single column:
SELECT prod_name from the products;
The returned result is unordered
- When retrieving multiple columns, add a comma between the column names:
SELECT prod_name, Prod_price from the products;
- Retrieve all columns and use wildcards to complete:
SELECT * from the products;
The biggest bit of the wildcard is the column that is retrieved so far
- Retrieve different lines, keyword distinct:
SELECT DISTINCT vend_id from the products;
- Search for restricted results:
SELECT prod_name from Products ; 5,5;
Instructs MySQL to retrieve 5 lines starting at line 5, Note that the first row retrieved is 0 instead of 1
Sort Retrieve data
MySQL Basics (i)