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

What are the common instruction operations in MySQL

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Editor to share with you what are commonly used instructions in MySQL operations, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!

L create database: CREATE DATABASE table_name

L delete database: DROP DATABASE table_name

L display database: SHOW DATABASE

L Select database: USE table_name

Note: all database names, table names, and field names in tables are case-sensitive. Therefore, we must use the appropriate name and then give any SQL command.

L create table: CREATE TABLE table_name (column_name column_type); / / column column

L delete table: DROP TABLE table_name

L rename table: ALTER TABLE table_name RENAME TO new name

L create an instance:

Create table table_tbl (table_id INT NOT NULL AUTO_INCREMENT, / / AUTO~ automatically adds the next available number table_title VARCHAR (100) NOT NULL in the id field, and / / the field uses the NOT NULL attribute. Users create records with table_author VARCHAR (40) NOT NULL, and records with NULL will report an error submission_date DATE, PRIMARY KEY (table_id) / / main keyword, which will not be changed after general allocation)

L insert data:

INSERT INTO table_name (field1, field2,...fieldN) VALUES (value1, value2,...valueN); / / pay attention to the definition of the column when creating the table.

L query display data:

SELECT field1, field2,...fieldN table_name1, table_ name 2. [where Clause] [OFFSET M] [LIMIT N] SELECT * from table_name; / / return all records SELECT * from table_name WHERE table_author='wonker'; / / return records whose author is wonker

L modify data:

UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause] UPDATE table_name SET table_title='Learning JAVA' WHERE table_id=3

L delete record:

DELETE FROM table_name [WHERE Clause] DELETE FROM table_tbl WHERE table_id=3

L remove, add, or redefine columns: ALTER command

The command for mysql to view the table structure is as follows:

L desc table name

L show columns from table name

L describe table name

L show create table table name

Due to the discontinuity of the numbering caused by the addition, deletion, modification and query of the database table, you can delete the number and then re-establish the number by the following methods:

ALTER TABLE table_tbl DROP title_author; / / remove ALTER TABLE table_tbl ADD num INT; / / add ALTER TABLE table_tbl ALTER num SET DEFAULT 1000; / / change the default value create table if not exists table_name (- -); this is all the content of the article "what are the common instruction operations in MySQL?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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