In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the specific steps of the basic operation of the SQL library in MySQL, the contents of the article are carefully selected and edited by the author, with a certain pertinence, and is of great significance to everyone's reference, the following is to understand the specific steps of the basic operation of the SQL library in MySQL with the author.
Basic operation of SQL
Basic operation: CURD, that is, add, delete, change and check.
Depending on the object of operation, we can divide the basic operations of SQL into three categories: library operations, table (field) operations, and data operations.
Library operation
1 add new database
Basic syntax: create database + database name + [library options]
Among them, the library option is used to constrain the database, which is optional (with default values). There are two types, namely:
Character set setting: charset/ character set+ specific character set, which is used to represent the encoding format of data storage. Commonly used character sets include GBK and UTF8.
Proofreading set setting: collate+ specific proofreading set, which represents the rules of data comparison, which depends on the character set.
Example: create database TBL_ERROR_CODE charset utf8
Among them, the database name cannot use keywords (characters that are already occupied, such as update and insert, etc.) or reserved words (which may be used in the future, such as access and cast, etc.).
If you must use the keyword or reserved word of the database as the database name, you must enclose it in backquotes, for example:
Create databaseaccesscharset utf8
If you also want to use Chinese as the name of the database, make sure that the database can recognize Chinese (it is strongly recommended not to name the database in Chinese), for example:
-- method to set the Chinese name, where gbk is the default character set of the current database, set names gbk;create database Beijing charset gbk
2 query the database
View all-> basic syntax: show databases
View section (fuzzy query)-> basic syntax: show databases like 'pattern'
Among them, pattern is a matching pattern, and there are two, which are:
%: indicates that multiple characters are matched
_: means to match a single character.
In addition, when matching a database name with an underscore _, you need to add a backslash before the underscore to escape.
Example: show databases like 'TBL%'; means to match all databases that begin with TBL.
View the database creation statement-> basic syntax: show create database + database name
Here, the result may be different from the SQL statement we wrote, because the database optimizes the SQL before executing the SQL statement, and the system saves the optimized result.
3 update the database
Here, it is important to note that the name of the database cannot be changed.
Modifications to the database are limited to the library option, that is, the character set and the proofreading set (the proofreading set depends on the character set).
Basic syntax: alter database + database name + [library options]
Charset/character set [=] character set
Collate [=] proofreading set
Example: alter database TBL_ERROR_CODE charset gbk; means to modify the character set of this database to gbk.
4 Delete the database
Basic syntax: drop database + database name
Here, it is important to note that before deleting the database, you should first perform a backup operation, because the deletion is irreversible, so do not delete the database at will.
Warm reminder: the content enclosed in the symbol [] indicates optional; the symbol + indicates the meaning of connection.
After reading the above specific steps about the basic operation of SQL library in MySQL, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.