MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently a product of Oracle. Today I will quickly introduce mysql to you!
1. Install mysql. Pay attention to the encoding selection, and use the default for everything else.
During installation, you need to enter the password to enter mysql, please set it to root. (Easy to remember and for my testing)
How to enter mysql:
Start --》Run--》Enter "mysql"
to enter the console interface as follows:
2. Enter the password you said you set. Accessible.
The interface after entering is as follows:
3. You can use the command at the "mysql>" prompt.
Mysql command is as follows:
Show databases; --显示所有数据库 Use 数据库名; ---进入某一个数据库中
4. At this time, you have entered the dinner In the database, operations such as creating tables can be performed.
You can use the basic syntax of sql table creation, addition, deletion, modification and query that you have learned below.
For example: Create table table name (field name field type constraint, field name field Type constraints,...)
Note: Mysql's automatic growth is different from sqlserver's.
Sqlserver’s automatic growth uses the identity keyword.
Mysql’s automatic growth uses auto_increment
For example:
5. Note:
1) If a field wants to be automatically grown, in mysql, it must be a primary key.
2) The syntax for setting a default value (the default value is a numeric type) constraint is default value
If the default value is set to a character type, the formula is as follows: default 'value'
In our daily development, we will write the sql table creation statement in advance, write it in a *****.sql file, and then import the file into mysql.
Then enter the mysql console and import this file, as follows:
6. Use the command:
source d:/mytable.sql
Note that I used the wrong slash at first and it couldn't be imported.
Now check to see if test1 and test2 already exist.
Notes
Note: show tables; This is the mysql command, which means to display all tables in a database. When working on web projects, don’t forget to import the mysql driver jar package into lib. Okay, this is the introductory tutorial to mysql. Well everyone.
The above is the detailed content of How to quickly master basic MySQL?. For more information, please follow other related articles on the PHP Chinese website!