Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of Mysql creation code example

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following content mainly brings you a detailed explanation of Mysql creation code examples, the knowledge here is slightly different from books, are summed up by professional and technical personnel in the process of contact with users, have a certain experience sharing value, hope to bring help to the majority of readers.

In order to work more clearly in Mysql, customize a set of specifications and several commonly used commands. Next I will learn how to create and operate a database of my own.

Grammatical norm

Keywords and function names must be capitalized

Database name, table name, field name must be all lowercase

The SQL statement must end with a semicolon

Commonly used commands

Displays the current CVM version

SELECT VERSION ()

Show current date and time

SELECT NOW ()

Show current user

SELECT USER ()

Note: all must end with a semicolon.

Create your own database

Let's first learn about the command to create a database in MYSQL

Create the database:

CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name

In the above syntax, {} is one of the must, and [] is writable but not writable. This is reassembled into a single command to create the database

/ / create a database named T1 CREATE DATABASE T1

Specify the database encoding:

[DEFAULT] CHARACTER SET [=] character_name

According to the previous syntax definition, let's reassemble the commands.

CREATE DATABASE t1 CHARACTER SET utf8

After we have created the database, how can we see if the database has been created successfully? It's very simple to use the SHOW command to print out all our data.

SHOW DATABASES

You can see that there are T1 and T2 databases in the data list.

Modify the specified database settings ALTER {DATABASES | SCHEMA} [db_name] [DEFAULT] CHARACTER SET [=] character_name

The combined command modifies the T2 database to gbkB encoding:

ALTER DATABASE t2 CHARACTER SET gbk

Let's take a look at the current code of the T1 database:

Command:

SHOW CREATE DATABASE t1

Now we can see that the T1 database is encoded as gbk.

So T1 and T2 are for testing, and we need to delete them now. You can use the DROP keyword.

Grammar rules:

DROP {DATABASE | SCHEMA} [IF EXISTS] db_name

Combine commands to delete data

DROP DATABASE t1

For the above detailed explanation of the Mysql creation code example, if you have more information, you can continue to pay attention to the innovation of our industry. If you need professional solutions, you can contact the pre-sales and after-sales on the official website. I hope this article can bring you some knowledge updates.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report