A summary of commonly used sql statements and the use of mysql database

Commonly used SQL statements

First start mysql

Insert picture description here
Run as administrator

Start the database:

net start mysql

Stop the database:

net stop mysql

Insert picture description here

sql statement

Create a table (not commonly used in development)

CREATE TABLE t_developer ( `name` VARCHAR(20) NOT NULL, `id` INT NOT NULL AUTO_INCREMENT, `password` VARCHAR(20) NOT NULL, `email` VARCHAR(20) NOT NULL, KEY(`id`), PRIMARY KEY (`name`) ); 

Operations on table tuples

INSERT INTO t_developer (`name`, `id`, `password`, `email`) VALUES ('小明', '1', '123456', '[email protected]');
INSERT INTO t_developer (`name`, `id`, `password`, `email`) VALUES ('小红', NULL, '123456', '[email protected]');//增

DELETE FROM t_developer WHERE `name` = '小红';//删

SELECT * FROM `t_developer` WHERE `name` = '小明'; //查

UPDATE `book`.`t_developer` SET `name` = '小李' WHERE `name` = '小红'; //改

Operations on attributes (generally not commonly used in development)

ALTER TABLE `t_developer` ADD COLUMN `sex` VARCHAR(10) NULL AFTER `email`;//增

ALTER TABLE `t_developer` DROP COLUMN `sex`; //删

ALTER TABLE `t_developer` CHANGE `email` `Email` VARCHAR(20) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL;//改

SQLyog interface operation:

Create a table to change the properties of a table
Insert picture description here
that has been created
Insert picture description here

Define/modify table attributes
Insert picture description here

In the corresponding table, right-click and click to open the table
Insert picture description here

Add/modify the content of the table to
Insert picture description here
delete tuples, select>right click>delete selected rows to
Insert picture description here
find specific tuples content
Enter the query statement and click the execute button in the upper left corner
Insert picture description here

Guess you like

Origin blog.csdn.net/m0_50654102/article/details/114321534