当前位置:网站首页>Common SQL commands

Common SQL commands

2022-04-23 19:09:00 Game programming

Catalog


First choose database

USE DatabaseName;
About table Code
establish table create table xx();
Copy table create table xx1 like xx;
change table name rename table xx to xx2;

establish table Writing

CREATE TABLE lesson (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(32) default '',
views int(11) NOT NULL default '0',
created_at DATETIME,
PRIMARY KEY (id,name)
FOREIGN KEY () REFERENCES XX()
);

alter code
Delete ALTER TABLE xx DROP COLUMN c
increase ALTER TABLE xx ADD COLUMN c a varchar(50)
renamed ALTER TABLE xx CHANGE COLUMN c C
Change properties ALTER TABLR xx CHANGE COLUMN c c age int()
increase primary key ALTER TABLE xx ADD CONSTRAINT Constraint name PRIMARY KEY
Delete primary key ALTER TABLE xx DROP primary key

to tablle Add data

SQL Common commands  -  The first 1 Zhang

Query data

duplicate problem

SQL Common commands  -  The first 6 Zhang
place table/column column Data processing Sort Customize table Data attribute
Code where avg,count oder by(desc,asc as null
in like some(select ...) exist
from distinct xx/unique(select) all(select..)
with having(group by) group by
between and

For select Must ignore null value

distinct & unique

SQL Common commands  -  The first 7 Zhang

Choice problem

SQL Common commands  -  The first 8 Zhang

Use where

SQL Common commands  -  The first 9 Zhang
SQL Common commands  -  The first 10 Zhang

Use like

SQL Common commands  -  The first 2 Zhang

Use in To execute multi table queries

SQL Common commands  -  The first 3 Zhang
SQL Common commands  -  The first 4 Zhang

as Usage: multi table query

SQL Common commands  -  The first 11 Zhang

some & as swap

SQL Common commands  -  The first 12 Zhang
SQL Common commands  -  The first 13 Zhang

Use many = Do multi table query

SQL Common commands  -  The first 14 Zhang

order by

SQL Common commands  -  The first 15 Zhang

Set performance

SQL Common commands  -  The first 16 Zhang

avg,count

SQL Common commands  -  The first 17 Zhang

group by

SQL Common commands  -  The first 5 Zhang

having

SQL Common commands  -  The first 18 Zhang

exits

SQL Common commands  -  The first 19 Zhang

author :DendenTaytay

Game programming ️, A game development favorite ~

If the picture is not displayed for a long time , Please use Chrome Kernel browser .

版权声明
本文为[Game programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231906382002.html