DAY02 MySQL Database basics
I. Overview of basic knowledge:
The foundation determines the success or failure of your course! Only after learning these basic knowledge, you can really be in the right. To be able to have a deeper understanding of the database, the road will go farther and further.
Second, the basic knowledge:
1 Database: The database is like a physical document cabinet, a container, we sorted out the data table and so on summed up.
To create a database command:
Create database name;
2. View the database
show databases;
3. Open the specified database
Use database name;
4. Delete Database
drop database name;
5, table: is a specific type of data structure of the list, plainly speaking is a form of a grid.
Commands for creating tables
CREATE TABLE table name (field name 1, field name 2,);
6. View Table Data
Show tables;
7. View Table Structure
describe table name;
8, Column: The concept of the column is not unfamiliar to everyone, that is, in the grid type of table in a vertical data is called a column.
9, row: Row is a row of data in the table, the data in the table is stored by an illumination row, the saved data are in the row.
10, primary key (primary key): This is a very important knowledge, in the follow-up we will also say, through the primary key when querying the data can be unique lock a row of data, in a database table can only have a primary key, but also a unique primary key.
11. Modify the table structure
alter table Table name add column Definition //add columns drop Column name //Delete Column add index index name (column name) //Add index drop index Index name //Delete index modify column Definition //modify column definition add primary key (column name) //Add primary key drop primary key //Delete primary Key rename New Table name // Modify Table Name
12. Inserting data
insert into table name [(column name,... N)] VALUES (value,...)
13. View the data in the table
Select column name [as alias] [,... n]|*| expression->from table name [,... n]->[where conditional expression]->[order by Column Name]->[group by column name]->[having conditional expression]
14. Delete data from the table
Delete from table name [where condition expression];
15. Modify the data in the table
Update table name set column name = value [where condition expression];
16. Delete a table
drop table name;
17. View: A view is a database table with a virtual presence that affects the corresponding database tables through the operation of the view, which reduces the operational database tables. You can also create one or more table extraction related fields as a single view that directly affects related database tables by manipulating the view.
Commands for creating views
CREATE view name as query fields for related tables
This article from "Lonely One Night" blog, reproduced please contact the author!
MySQL Database Basics