Get the App
SLTechnology News&Howtos  ›  Database  › 

A brief Analysis of adding, deleting, modifying and searching MySQL

Shulou Source: shulou.com Published: 2022-06-01 20:09:51 10月04日 Update

The following is mainly to bring you to add, delete and check MySQL analysis, I hope that add, delete and check MySQL analysis can bring you practical use, this is also the main purpose of my editing this article. Okay, no more nonsense, let's go straight to the following.

MySQL relational database RDS in the very foundation is also very important, add, delete and change is the basis of MySQL entry, database it to say MySQL database add, delete and change common statements.

Add, delete, and search statements:

Added: insert

Delete: delete

Update: Update

Select or Show

Library operations:

Create database shujukuba;

Create database mydb2 CHARACTER SET=utf8;

Create database mydb3 CHARACTER SET=utf8 COLATE utf8_general_ci;

Show databases: show databases;

Delete database: DROP DATABASE shujukuba;

Alter DATABASE shujukuba character set gb2312;

Table operations:

Create a database table (create a table named employee, which contains id, name, sex, birthday, job fields):

create table employee(

id int,

name varchar(40),

sex char(4),

birthday date,

job varchar(100),);

Add image field to table: alter table employee add image blob; modify job value to 60(original length is 1000): alter table employee modify job varchar(60);

Delete sex column: alter table employee drop sex; change table name to user(formerly employee): rename table employee to user;

Change the character set of the table to utf-8: alter table user character set utf8;

column name changed to username: alter table user change column name username varchar(100);

drop table user;

Example Preparation Table for Addition, Deletion, Revision and Query:

create table employee

(

id int,

name varchar(40),

sex varchar(4),

birthday data,

salary decimal(8,2),

resume text

);

Insert table data:

insert into employee(id,name,sex,birthday,entry_date,salary,resume)values(1,'zhangsan','male','1993-03-04','2016-11-10','1000','i am a developer');

insert into employee(id) values(6);

insert into employee(id,name) values(6,'Zhang San');

Modify table data:

Modify the salary of all employees to 5000 yuan: update employee set salary=5000; modify the salary of the employee named 'zs' to 3000 yuan: update employee set salary = 3000 where name='zhangsan';

Change the salary of the employee whose name is 'aaa' to 4000 yuan,job to ccc: update employee set salary = 4000,job='ccc' where name='Zhang San';

Increase wu's salary by 1000 yuan on the original basis: update employee set salary = salary+1000 where name='Zhang San';

Delete table data:

Delete from employee where job='ccc';

Delete all records in the table: delete from employee;

Use truncate to delete records in the table: truncate table employee;

Query table data: Wuxi Bohai Hospital https://yyk.familydoctor.com.cn/20612/

Select id,name,chinese,english,math from student;

Select name,English from student;

Select * from student where name='Zhang San';

Select * from students where English>'90';

Select * from students where English>=80 and English=

Tags: Data database query statement salary Zhang San employee foundation field character student grade query table English following text content classmate command character set common Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB Shulou Information Xiaomi Linux