Commonly used SQL statements
First start mysql
Run as administrator
Start the database:
net start mysql
Stop the database:
net stop mysql
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
that has been created
Define/modify table attributes
In the corresponding table, right-click and click to open the table
Add/modify the content of the table to
delete tuples, select>right click>delete selected rows to
find specific tuples content
Enter the query statement and click the execute button in the upper left corner