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
Key Points The CSS resize property allows you to ...
This article uses examples to illustrate the simp...
This is an enhanced version. The questions and SQ...
operating system: Win10 Home Edition Install Dock...
When using nginx as a reverse proxy, you can simp...
1. Install dependency packages [root@localhost ~]...
Table of contents mousejoint mouse joint distance...
Table of contents 1. Download 2. Deployment 3. Ng...
Copy code The code is as follows: height:auto !im...
Preface This article mainly shares with you an ex...
This article shares the specific code for JavaScr...
Six steps to install MySQL (only the installation...
System: Ubuntu 16.04LTS 1\Download mysql-5.7.18-l...
Table of contents Preface Is there any hope after...
Specific method: First open the command prompt; T...