Basic Summary of MySql (1), basic summary of mysql

Source: Internet
Author: User
Tags sql server query mysql tutorial

Basic Summary of MySql (1), basic summary of mysql

I have read MySql for the second time. The main purpose of this time is to sum up the MySql system. I used to write my notes on MySql before, but I don't want to always take it with me in the future, so I will spend some time summarizing my notes in my blog. The installation steps have been detailed in the afternoon, and now the basic syntax is summarized. Many of the syntaxes meet the SQL syntax, which is similar to SQL Server and Oracle. All the items that match ">" are verified in dos and can be run directly after replication.

1. Connect to the database:

> # In mysql, '#' is the annotation symbol. When connecting to the database, enter the account and password.

> Mysql-u root-p wwh

2. display all databases

> Show databases;

3. Switch to display a database

> Use test;

4. display all tables in the corresponding database:
> Show tables;

5. Create a database named "user"
> Create database user;
6. Create a user database using the utf8 Character Set
> Create database if not exists user character set UTF8;
> # If no user exists, create the database. If yes, no user database is created.
7. Create a user database that uses the utf8 Character Set and has verification rules
> Create database if not exists user character set UTF8 collate utf8_general_ci;

8. view the definition information of the user database created earlier.
> Show create database user;

9. Delete the user database created earlier
> Drop database if exists user;

10. view the database on the server and modify the character set of the user database to gbk.
> Alter database user character set gbk;

11. Modify, back up, and recover database data (this should be unique in MySql. Different database backup and recovery commands are different)
Backup:
C: \> mysqldump-u root-p wwh> d: \ user. SQL enter (you can end with a semicolon)
Press ENTER
Note: This SQL command is unique to MySQL and must be executed outside the MySQL environment. That is, it is executed in the dos interface environment in the Window and is not entered into the MySql server.
Recovery:
Mysql: \> source d: \ mydb2. SQL; press enter (you need to end with a semicolon)
Note: This SQL command is unique to MySQL and must be executed in the MySQL environment.

12. MySQL supports data types


Note:

(1)Date/Datetime/TimeStamp, the delimiters use ''or" "(single quotes and double quotes), but some databases may not support" ". We recommend'' as the delimiters first. For Date types, mySQL database has a segment determination Function
(2) varchar (variable length)/char (fixed length)
(3) Text (Data larger than 65536 characters)/Blob (storage of binary multimedia data, such as Mp3), the two types have four sub-types, depending on the size of the storage content to select
(4) The INT type can be signed or unsigned. int (5) indicates that the default value of int Is 5 bits. If the value of id is inserted, it must be smaller than 5 bits and left with spaces. If the value of id is inserted, the value must be greater than 5 characters, which is determined based on the inserted value but must meet the size of the int type.

(5) FLOAT (M, D), D indicates the D digit after the decimal point. It is calculated by rounding. M indicates the total number of all digits except the decimal point.

(6)Tinyint/smallint/mediumint/int/bigint --> 1B/2B/3B/4B/8B

13. Optimization Methods:

Use Time for space or space for time.

14. Note:

In actual development, you can consider frequently used information, give priority to efficiency, store it in a table, and take less frequently used information and space-consuming information for a limited consideration, store the data in the secondary table. For example, the user name and password in the QQ space, and the storage of logs and message boards.





















How to get started with mysql?

1. When I create a Database and use it again, the Database changed and I don't know what to do.
Database changed indicates that you can now operate the data in the Database to be moved to. Next we can use select query, delete with delete, and update with update, you can also write and call more powerful stored procedures and triggers ~ A lot of things can be done ~ But it will take 1.1 ~
2. I have never understood. Is the database created on my own computer?
The database is built on your computer ~ Of course, the data structure should be used to organize and store the data. You don't have to worry about how to store data. You should first start with the application.
3. How to establish data connection with other computers
If you are learning C, you can use ODBC for connection (MicroSoft's development tools and languages basically use this). If you are using java later, you can use jdbc. This should not be too urgent.
4. What is the use of the sample database?
The sample database can be used to test whether the database is successfully loaded.
For beginners, it can also be used for exercises (you can use these existing tables to practice DML before you have mastered the DDL language ).

This may be a bit messy.
I remember when we started talking about relational databases, entities, relationships, relational algebra, and functional dependencies .... After talking about a lot of basic knowledge about biased principles, you can start to operate on the machine.
However, if you are self-taught, we recommend that you operate it first and then see why.
I don't know if your "Mysql technology insider" is in the fourth version. I just got a copy of it online. It's a good book. But I suggest you follow the instructions in Chapter 2 to learn how to operate the database first, in this way, you can get started quickly, establish a sense of accomplishment, and be more interested in learning.
In combination with this, you can find a video on the Internet (the kind of project promotion), with a fast gesture.
There are not many young people who love reading books or playing games. Good luck ~

How to use MYSQL should start from the beginning, and it should be done by a beginner at a glance.

Basic Mysql tutorial

· How to use stored procedures and triggers to manage data [May September 13] · experience on MySQL coding [May August 23] · SQL Server 2005 CE basic overview [May August 17] · SQL Server executes SQL statements features of memory usage during [July 22, July 31] · method for parsing SQL Server transaction log compression and deletion [July 22, July 30] · handling of update errors after sql2005 is installed [July 22, July 30] · SQL Server and Oracle, comparison of the three types of databases in DB2 [] · common SQL syntax and Data Objects in ORACLE [] · creating a security policy for SQL Server [] · Quickly Understanding SELECT statements in the MySQL database [] · MYSQL error code list for beginners of databases [June 20] · MySQL 5.0 new feature tutorial stored procedure: lecture 2: stored procedures in the new MySQL June 17 tutorial [July 5.0: lecture 1 [July 22, June 16] · How to directly store images in the MySQL database [July 22, June 16] · SQL Server Query analyzer shortcut keys set [July 22, June 14]
Reference: edu.itbulo.com/db/mysql/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.