This article uses examples to describe how to use MySQL statements to implement simple add, delete, modify, and query operations. Share with you for your reference, the details are as follows: 1. Create the db_shop database. If the database does not exist, create it create database if not exists db_shop; 2. Delete the database if the data exists drop database if exists db_shop; 3. Create a data table for db_shop use db_shop; drop table if exists tb_goods; CREATE TABLE tb_goods( `goodsId` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`tb_goods`) ); 4. Create a new table based on the old table create table tb_goods01 like tb_goods; 5. Delete the data table drop table tb_goods01; 6. Add a column (a field) to a table alter tb_goods add column goodsName varchar(255) after goodsId; Note: If you don't write after or before, it will be added to the end by default 7. Delete fields alter table tb_goods drop column goodsName; 8. Insert data insert into tb_goods (goodsId,goodsName) values (1002,'Commodity 1'); 9. Query Search all select * from tb_goods; Query Specific select goodsName from tb_goods; Fuzzy search select * from tb_goods like '% Commodity%'; 10. Update the data table update tb_goods set goodsName='Commodity 2'; Readers who are interested in more MySQL-related content can check out the following topics on this site: "MySQL query skills", "MySQL common functions summary", "MySQL log operation skills", "MySQL transaction operation skills summary", "MySQL stored procedure skills" and "MySQL database lock related skills summary" I hope this article will be helpful to everyone's MySQL database design. You may also be interested in:
|
>>: Implementation of webpack code fragmentation
Method 1: Submit via the submit button <!DOCTY...
Import and export of Docker images This article i...
This article example shares the specific code of ...
Table of contents 1. What does shallow copy mean?...
Today I received a disk warning notification from...
Apache Superset is a powerful BI tool that provid...
1. MacVlan There are many solutions to achieve cr...
Table of contents Overview in operator refinement...
method: Take less in the actual project as an exa...
Solution: Bind the click event to the audio compo...
1: Download from mysql official website https://d...
Effect check address: Tour plan (uplanok.com) Cod...
When the server needs to be started during develo...
This article is mainly to take you to quickly und...
Table of contents Docker version Install Docker E...