当前位置:网站首页>MySQL Basics

MySQL Basics

2022-06-12 19:50:00 WD Technology

Database creation 、 Delete
CREATE DATABASE test

DROP DATABASE test;

The creation of a table
CREATE TABLE < Table name >(
< List name 1> < data type > < The constraints required by this column >
< List name 2> < data type > < The constraints required by this column >
< List name 3> < data type > < The constraints required by this column >
……
PRIMARY KEY < List name 1, List name 2……> – Set a column or columns as the primary key as required
);

Deleting and updating tables 、 Modify the name of the table , Change column names
The deletion of the table is implemented in code as follows
DROP TABLE < List name >;

Add a column to the table and code it as follows :
ALTER TABLE < Table name > ADD COLUMN < Name , data type , constraint condition >;

Delete a column of code in the table to achieve the following :
ALTER TABLE < Table name > DROP COLUMN < Name >;

Modify table name code :
ALTER TABLE < The old name of the table > rename AS < The new name of the table >

Modify column name code :
ALTER TABLE < Table name > change < Old column names 1> < New column names 1> < data type > < constraint condition >,
change < Old column names 2> < New column names 2> < data type > < constraint condition >,
……;

Data insertion 、 Delete and update
Insert
INSERT INTO < Table name > ( Name 1, Name 2,… )
VALUES( The number 1, The number 2,… );

SQL Three points should be paid attention to in the writing rules of
SQL All statements are based on ; ending
SQL Statements are case insensitive for keywords
The input symbols must all be English symbols

Add :
https://www.cnblogs.com/vuciao/p/10586773.html

原网站

版权声明
本文为[WD Technology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202281534382385.html