Home > Database > Mysql Tutorial > How to quickly master basic MySQL?

How to quickly master basic MySQL?

黄舟
Release: 2017-08-02 11:02:59
Original
1407 people have browsed it

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:

How to quickly master basic MySQL?

2. Enter the password you said you set. Accessible.

The interface after entering is as follows:

How to quickly master basic MySQL?

3. You can use the command at the "mysql>" prompt.

Mysql command is as follows:

Show  databases;   --显示所有数据库
Use  数据库名;      ---进入某一个数据库中
Copy after login

How to quickly master basic MySQL?

How to quickly master basic MySQL?

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:

How to quickly master basic MySQL?

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:

How to quickly master basic MySQL?

6. Use the command:

source  d:/mytable.sql
Copy after login

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.

How to quickly master basic MySQL?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template