feat: #190 improve mysql grammer (#196)

* refactor: generic rename to mysql

* refactor: g4 with mysql syntax

* test: mysql syntax

* refactor: remove useless keywords

* refactor: remove nonReserved keywords

* refactor: lint specificFunction

---------

Co-authored-by: liuyi <liuyi@dtstack.com>
This commit is contained in:
琉易 2023-11-27 15:25:40 +08:00 committed by GitHub
parent 84b2d776dc
commit 428d851913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
139 changed files with 123150 additions and 110286 deletions

View File

@ -19,7 +19,7 @@ yarn test
Compile one language:
```bash
yarn antlr4 --lang=generic
yarn antlr4 --lang=mysql
```
Compile all languages:

View File

@ -64,7 +64,7 @@ function main() {
compile(language);
});
} else if (argv.lang) {
// compile single: yarn antlr4 --lang=generic
// compile single: yarn antlr4 --lang=mysql
const supportedLanguage = languageEntries.some((language) => language === argv.lang);
if (supportedLanguage) {
compile(argv.lang);

View File

@ -1,3 +0,0 @@
# MySQL Grammar
[MySQL Grammar](https://github.com/mysql/mysql-workbench/tree/8.0/library/parsers/grammars)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@ export * from './parser';
export * from './utils';
export * from './lib/flinksql/FlinkSqlParserListener';
export * from './lib/flinksql/FlinkSqlParserVisitor';
export * from './lib/generic/SqlParserVisitor';
export * from './lib/generic/SqlParserListener';
export * from './lib/mysql/MySqlParserVisitor';
export * from './lib/mysql/MySqlParserListener';
export * from './lib/hive/HiveSqlParserListener';
export * from './lib/hive/HiveSqlParserVisitor';
export * from './lib/plsql/PlSqlParserListener';

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

6918
src/lib/mysql/MySqlLexer.ts Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

84250
src/lib/mysql/MySqlParser.ts Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
export { default as GenericSQL } from './generic';
export { default as MySQL } from './mysql';
export { default as PLSQL } from './plsql';
export { default as HiveSQL } from './hive';
export { default as FlinkSQL } from './flinksql';

View File

@ -1,18 +1,18 @@
import { Token } from 'antlr4ts';
import { CandidatesCollection } from 'antlr4-c3';
import { SqlLexer } from '../lib/generic/SqlLexer';
import { SqlParser, ProgramContext } from '../lib/generic/SqlParser';
import { MySqlLexer } from '../lib/mysql/MySqlLexer';
import { MySqlParser, ProgramContext } from '../lib/mysql/MySqlParser';
import BasicParser from './common/basicParser';
import { Suggestions } from './common/basic-parser-types';
export default class GenericSQL extends BasicParser<SqlLexer, ProgramContext, SqlParser> {
protected createLexerFormCharStream(charStreams): SqlLexer {
const lexer = new SqlLexer(charStreams);
export default class MySQL extends BasicParser<MySqlLexer, ProgramContext, MySqlParser> {
protected createLexerFormCharStream(charStreams): MySqlLexer {
const lexer = new MySqlLexer(charStreams);
return lexer;
}
protected createParserFromTokenStream(tokenStream): SqlParser {
return new SqlParser(tokenStream);
protected createParserFromTokenStream(tokenStream): MySqlParser {
return new MySqlParser(tokenStream);
}
protected preferredRules: Set<number> = new Set();

View File

@ -1,12 +0,0 @@
import GenericSQL from '../../../src/parser/generic';
describe('GenericSQL Lexer tests', () => {
const mysqlParser = new GenericSQL();
const sql = 'select id,name,sex from user1;';
const tokens = mysqlParser.getAllTokens(sql);
test('token counts', () => {
expect(tokens.length).toBe(12);
});
});

View File

@ -0,0 +1,12 @@
import MySQL from '../../../src/parser/mysql';
describe('MySQL Lexer tests', () => {
const parser = new MySQL();
const sql = 'select id,name,sex from user1;';
const tokens = parser.getAllTokens(sql);
test('token counts', () => {
expect(tokens.length).toBe(12);
});
});

View File

@ -1,17 +1,17 @@
import GenericSQL from '../../../src/parser/generic';
import { SqlParserListener } from '../../../src/lib/generic/SqlParserListener';
import MySQL from '../../../src/parser/mysql';
import { MySqlParserListener } from '../../../src/lib/mysql/MySqlParserListener';
import { ParseTreeListener } from 'antlr4ts/tree';
describe('Generic SQL Listener Tests', () => {
describe('MySQL Listener Tests', () => {
const expectTableName = 'user1';
const sql = `select id,name,sex from ${expectTableName};`;
const parser = new GenericSQL();
const parser = new MySQL();
const parseTree = parser.parse(sql);
test('Listener enterTableName', async () => {
let result = '';
class MyListener implements SqlParserListener {
class MyListener implements MySqlParserListener {
enterTableName = (ctx): void => {
result = ctx.text.toLowerCase();
};

View File

@ -1,7 +1,7 @@
import GenericSQL from '../../../src/parser/generic';
import MySQL from '../../../src/parser/mysql';
describe('Generic SQL Syntax Tests', () => {
const parser = new GenericSQL();
describe('MySQL Syntax Tests', () => {
const parser = new MySQL();
test('Select Statement', () => {
const sql = 'select id,name from user1;';

View File

@ -0,0 +1,51 @@
import MySQL from '../../../../src/parser/mysql';
import { readSQL } from '../../../helper';
const parser = new MySQL();
const features = {
alterUser: readSQL(__dirname, 'alterUser.sql'),
createRole: readSQL(__dirname, 'createRole.sql'),
createUser: readSQL(__dirname, 'createUser.sql'),
dropRole: readSQL(__dirname, 'dropRole.sql'),
dropUser: readSQL(__dirname, 'dropUser.sql'),
grant: readSQL(__dirname, 'grant.sql'),
renameUser: readSQL(__dirname, 'renameUser.sql'),
revoke: readSQL(__dirname, 'revoke.sql'),
setDefaultRole: readSQL(__dirname, 'setDefaultRole.sql'),
setPassword: readSQL(__dirname, 'setPassword.sql'),
setRole: readSQL(__dirname, 'setRole.sql'),
alterResourceGroup: readSQL(__dirname, 'alterResourceGroup.sql'),
createResourceGroup: readSQL(__dirname, 'createResourceGroup.sql'),
dropResourceGroup: readSQL(__dirname, 'dropResourceGroup.sql'),
setResourceGroup: readSQL(__dirname, 'setResourceGroup.sql'),
analyzeTable: readSQL(__dirname, 'analyzeTable.sql'),
checkTable: readSQL(__dirname, 'checkTable.sql'),
checkSumTable: readSQL(__dirname, 'checkSumTable.sql'),
optimizeTable: readSQL(__dirname, 'optimizeTable.sql'),
repairTable: readSQL(__dirname, 'repairTable.sql'),
installComponent: readSQL(__dirname, 'installComponent.sql'),
installPlugin: readSQL(__dirname, 'installPlugin.sql'),
uninstallComponent: readSQL(__dirname, 'uninstallComponent.sql'),
uninstallPlugin: readSQL(__dirname, 'uninstallPlugin.sql'),
clone: readSQL(__dirname, 'clone.sql'),
set: readSQL(__dirname, 'set.sql'),
setCharacterSet: readSQL(__dirname, 'setCharacterSet.sql'),
setNames: readSQL(__dirname, 'setNames.sql'),
show: readSQL(__dirname, 'show.sql'),
otherAdministrative: readSQL(__dirname, 'otherAdministrative.sql'),
};
describe('MySQL Database Administration Syntax Tests', () => {
Object.keys(features).forEach((key) => {
features[key].forEach((sql) => {
it(sql, () => {
const result = parser.validate(sql);
if (result.length) {
console.log(result, `\n请检查 sql: ${sql}`);
}
expect(result.length).toBe(0);
});
});
});
});

View File

@ -0,0 +1,58 @@
import MySQL from '../../../../src/parser/mysql';
import { readSQL } from '../../../helper';
const parser = new MySQL();
const features = {
alterDatabase: readSQL(__dirname, 'alterDatabase.sql'),
alterEvent: readSQL(__dirname, 'alterEvent.sql'),
alterFunction: readSQL(__dirname, 'alterFunction.sql'),
alterInstance: readSQL(__dirname, 'alterInstance.sql'),
alterLogFileGroup: readSQL(__dirname, 'alterLogFileGroup.sql'),
alterProcedure: readSQL(__dirname, 'alterProcedure.sql'),
alterServer: readSQL(__dirname, 'alterServer.sql'),
alterTable: readSQL(__dirname, 'alterTable.sql'),
alterTableAndGeneratedColumns: readSQL(__dirname, 'alterTableAndGeneratedColumns.sql'),
alterTablePartition: readSQL(__dirname, 'alterTablePartition.sql'),
alterTableSpace: readSQL(__dirname, 'alterTableSpace.sql'),
alterView: readSQL(__dirname, 'alterView.sql'),
createDatabase: readSQL(__dirname, 'createDatabase.sql'),
createEvent: readSQL(__dirname, 'createEvent.sql'),
createFunction: readSQL(__dirname, 'createFunction.sql'),
createIndex: readSQL(__dirname, 'createIndex.sql'),
createLogFileGroup: readSQL(__dirname, 'createLogFileGroup.sql'),
createProcedure: readSQL(__dirname, 'createProcedure.sql'),
createServer: readSQL(__dirname, 'createServer.sql'),
createTable: readSQL(__dirname, 'createTable.sql'),
createTableSpace: readSQL(__dirname, 'createTableSpace.sql'),
createTrigger: readSQL(__dirname, 'createTrigger.sql'),
createView: readSQL(__dirname, 'createView.sql'),
dropDatabase: readSQL(__dirname, 'dropDatabase.sql'),
dropEvent: readSQL(__dirname, 'dropEvent.sql'),
dropFunction: readSQL(__dirname, 'dropFunction.sql'),
dropIndex: readSQL(__dirname, 'dropIndex.sql'),
dropLogFileGroup: readSQL(__dirname, 'dropLogFileGroup.sql'),
dropProcedure: readSQL(__dirname, 'dropProcedure.sql'),
dropServer: readSQL(__dirname, 'dropServer.sql'),
dropSpatialReferenceSystem: readSQL(__dirname, 'dropSpatialReferenceSystem.sql'),
dropTable: readSQL(__dirname, 'dropTable.sql'),
dropTableSpace: readSQL(__dirname, 'dropTableSpace.sql'),
dropTrigger: readSQL(__dirname, 'dropTrigger.sql'),
dropView: readSQL(__dirname, 'dropView.sql'),
renameTable: readSQL(__dirname, 'renameTable.sql'),
truncateTable: readSQL(__dirname, 'truncateTable.sql'),
};
describe('MySQL DDL Syntax Tests', () => {
Object.keys(features).forEach((key) => {
features[key].forEach((sql) => {
it(sql, () => {
const result = parser.validate(sql);
if (result.length) {
console.log(result, `\n请检查 sql: ${sql}`);
}
expect(result.length).toBe(0);
});
});
});
});

View File

@ -0,0 +1,42 @@
import MySQL from '../../../../src/parser/mysql';
import { readSQL } from '../../../helper';
const parser = new MySQL();
const features = {
call: readSQL(__dirname, 'call.sql'),
delete: readSQL(__dirname, 'delete.sql'),
do: readSQL(__dirname, 'do.sql'),
handler: readSQL(__dirname, 'handler.sql'),
importTable: readSQL(__dirname, 'importTable.sql'),
insert: readSQL(__dirname, 'insert.sql'),
insertSelect: readSQL(__dirname, 'insertSelect.sql'),
interSect: readSQL(__dirname, 'interSect.sql'),
loadData: readSQL(__dirname, 'loadData.sql'),
loadXml: readSQL(__dirname, 'loadXml.sql'),
parenthesizedQuery: readSQL(__dirname, 'parenthesizedQuery.sql'),
replace: readSQL(__dirname, 'replace.sql'),
select: readSQL(__dirname, 'select.sql'),
selectJoin: readSQL(__dirname, 'selectJoin.sql'),
setOperations: readSQL(__dirname, 'setOperations.sql'),
subQueries: readSQL(__dirname, 'subQueries.sql'),
table: readSQL(__dirname, 'table.sql'),
update: readSQL(__dirname, 'update.sql'),
union: readSQL(__dirname, 'union.sql'),
values: readSQL(__dirname, 'values.sql'),
with: readSQL(__dirname, 'with.sql'),
};
describe('MySQL DML Syntax Tests', () => {
Object.keys(features).forEach((key) => {
features[key].forEach((sql) => {
it(sql, () => {
const result = parser.validate(sql);
if (result.length) {
console.log(result, `\n请检查 sql: ${sql}`);
}
expect(result.length).toBe(0);
});
});
});
});

View File

@ -0,0 +1,20 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-database.html
/* ALTER {DATABASE | SCHEMA} [db_name]
alter_option ...
alter_option: {
[DEFAULT] CHARACTER SET [=] charset_name
| [DEFAULT] COLLATE [=] collation_name
| [DEFAULT] ENCRYPTION [=] {'Y' | 'N'}
| READ ONLY [=] {DEFAULT | 0 | 1}
} */
ALTER DATABASE mydb READ ONLY = 0 DEFAULT COLLATE utf8mb4_bin;
ALTER SCHEMA mydb READ ONLY = 1 DEFAULT COLLATE utf8mb4_bin;
ALTER DATABASE READ ONLY = DEFAULT;
ALTER DATABASE mydb READ ONLY = 0;
ALTER DATABASE mydb READ ONLY = 1;

View File

@ -0,0 +1,26 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-event.html
/* ALTER
[DEFINER = user]
EVENT event_name
[ON SCHEDULE schedule]
[ON COMPLETION [NOT] PRESERVE]
[RENAME TO new_event_name]
[ENABLE | DISABLE | DISABLE ON SLAVE]
[COMMENT 'string']
[DO event_body] */
ALTER EVENT no_such_event ON SCHEDULE EVERY '2:3' DAY_HOUR;
ALTER EVENT myevent ON SCHEDULE EVERY 12 HOUR STARTS CURRENT_TIMESTAMP + INTERVAL 4 HOUR;
ALTER EVENT myevent ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY DO TRUNCATE TABLE myschema.mytable;
ALTER EVENT myevent DISABLE;
ALTER EVENT myevent RENAME TO yourevent;
ALTER EVENT myevent RENAME TO yourevent;
ALTER EVENT olddb.myevent RENAME TO newdb.myevent;

View File

@ -0,0 +1,23 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-function.html
/* ALTER FUNCTION func_name [characteristic ...]
characteristic: {
COMMENT 'string'
| LANGUAGE SQL
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
} */
ALTER FUNCTION function_name;
ALTER FUNCTION function_name COMMENT 'get id';
ALTER FUNCTION function_name COMMENT 'get id' LANGUAGE SQL;
ALTER FUNCTION function_name LANGUAGE SQL;
ALTER FUNCTION function_name NOT DETERMINISTIC;
ALTER FUNCTION function_name CONTAINS SQL;
ALTER FUNCTION function_name NO SQL;
ALTER FUNCTION function_name READS SQL DATA;
ALTER FUNCTION function_name MODIFIES SQL DATA;
ALTER FUNCTION function_name SQL SECURITY DEFINER;
ALTER FUNCTION function_name SQL SECURITY INVOKER;

View File

@ -0,0 +1,16 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-instance.html
/* ALTER INSTANCE instance_action
instance_action: {
| {ENABLE|DISABLE} INNODB REDO_LOG
| ROTATE INNODB MASTER KEY
| ROTATE BINLOG MASTER KEY
| RELOAD TLS
[FOR CHANNEL {mysql_main | mysql_admin}]
[NO ROLLBACK ON ERROR]
| RELOAD KEYRING
} */
ALTER INSTANCE ROTATE INNODB MASTER KEY;

View File

@ -0,0 +1,14 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-logfile-group.html
/* ALTER LOGFILE GROUP logfile_group
ADD UNDOFILE 'file_name'
[INITIAL_SIZE [=] size]
[WAIT]
ENGINE [=] engine_name */
ALTER LOGFILE GROUP lg_3 ADD UNDOFILE 'undo_10.dat' INITIAL_SIZE=32M ENGINE=NDBCLUSTER;
ALTER LOGFILE GROUP lg_3 ADD UNDOFILE 'undo_10.dat' ENGINE=NDBCLUSTER;
ALTER LOGFILE GROUP lg_3 ADD UNDOFILE 'undo_10.dat' INITIAL_SIZE=32M WAIT ENGINE=NDBCLUSTER;
ALTER LOGFILE GROUP lg_3 ADD UNDOFILE 'undo_10.dat' WAIT ENGINE=NDBCLUSTER;

View File

@ -0,0 +1,25 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-procedure.html
/* ALTER PROCEDURE proc_name [characteristic ...]
characteristic: {
COMMENT 'string'
| LANGUAGE SQL
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
} */
-- 和 ALTER FUNCTION 语法类似
ALTER PROCEDURE procedure_name;
ALTER PROCEDURE procedure_name COMMENT 'get id';
ALTER PROCEDURE procedure_name COMMENT 'get id' LANGUAGE SQL;
ALTER PROCEDURE procedure_name LANGUAGE SQL;
ALTER PROCEDURE procedure_name NOT DETERMINISTIC;
ALTER PROCEDURE procedure_name CONTAINS SQL;
ALTER PROCEDURE procedure_name NO SQL;
ALTER PROCEDURE procedure_name READS SQL DATA;
ALTER PROCEDURE procedure_name MODIFIES SQL DATA;
ALTER PROCEDURE procedure_name SQL SECURITY DEFINER;
ALTER PROCEDURE procedure_name SQL SECURITY INVOKER;

View File

@ -0,0 +1,25 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-resource-group.html
/* ALTER RESOURCE GROUP group_name
[VCPU [=] vcpu_spec [, vcpu_spec] ...]
[THREAD_PRIORITY [=] N]
[ENABLE|DISABLE [FORCE]]
vcpu_spec: {N | M - N} */
ALTER RESOURCE GROUP group_name VCPU = 2, 3 THREAD_PRIORITY = 5 DISABLE FORCE;
ALTER RESOURCE GROUP group_name VCPU = 2, 3 THREAD_PRIORITY = 5 ENABLE FORCE;
ALTER RESOURCE GROUP group_name VCPU 2 THREAD_PRIORITY 5 ENABLE FORCE;
ALTER RESOURCE GROUP group_name VCPU 2 THREAD_PRIORITY 5 ENABLE;
ALTER RESOURCE GROUP group_name VCPU 2 THREAD_PRIORITY 5 DISABLE;
ALTER RESOURCE GROUP group_name VCPU 2 THREAD_PRIORITY 5;
ALTER RESOURCE GROUP group_name VCPU 2 DISABLE FORCE;
ALTER RESOURCE GROUP group_name DISABLE FORCE;
ALTER RESOURCE GROUP group_name ENABLE FORCE;
ALTER RESOURCE GROUP group_name;
ALTER RESOURCE GROUP rg1 VCPU = 0-63;
ALTER RESOURCE GROUP rg1 VCPU = 0-63, 64-65, 66;
ALTER RESOURCE GROUP rg2 THREAD_PRIORITY = 5;
ALTER RESOURCE GROUP rg3 DISABLE FORCE;

View File

@ -0,0 +1,7 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-server.html
/* ALTER SERVER server_name
OPTIONS (option [, option] ...) */
ALTER SERVER server_name OPTIONS (USER 'sally');

View File

@ -0,0 +1,105 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-table.html
ALTER TABLE t2 DROP COLUMN c, DROP COLUMN d;
ALTER TABLE t1 ENGINE = InnoDB;
ALTER TABLE t1 ROW_FORMAT = COMPRESSED;
ALTER TABLE t1 AUTO_INCREMENT = 13;
ALTER TABLE t1 CHARACTER SET = utf8mb4;
ALTER TABLE t1 COMMENT = 'New table comment';
ALTER TABLE t1 COMMENT = 'NDB_TABLE=READ_BACKUP=0,PARTITION_BALANCE=FOR_RA_BY_NODE';
ALTER TABLE t1 CHANGE COLUMN old_col_name new_col_name BLOB COMMENT 'NDB_COLUMN=BLOB_INLINE_SIZE=4096,MAX_BLOB_PART_SIZE';
ALTER TABLE t1 CHANGE a b BIGINT NOT NULL;
ALTER TABLE t1 CHANGE b b INT NOT NULL;
ALTER TABLE t1 MODIFY b INT NOT NULL;
ALTER TABLE t1 CHANGE b a INT NOT NULL;
ALTER TABLE t1 RENAME COLUMN b TO a;
-- swap a and b
ALTER TABLE t1 RENAME COLUMN a TO b,
RENAME COLUMN b TO a;
-- "rotate" a, b, c through a cycle
ALTER TABLE t1 RENAME COLUMN a TO b,
RENAME COLUMN b TO c,
RENAME COLUMN c TO a;
ALTER TABLE t1 MODIFY col1 BIGINT;
ALTER TABLE t1 MODIFY col1 BIGINT UNSIGNED DEFAULT 1 COMMENT 'my column';
ALTER TABLE tbl_name DROP CHECK symbol;
ALTER TABLE tbl_name DROP CONSTRAINT symbol;
ALTER TABLE t MODIFY latin1_text_col TEXT CHARACTER SET utf8mb4;
ALTER TABLE t MODIFY latin1_varchar_col VARCHAR CHARACTER SET utf8mb4;
ALTER TABLE tbl_name CONVERT TO CHARSET utf8mb4;
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8mb4;
ALTER TABLE tbl_name DEFAULT CHARACTER SET utf8mb4;
ALTER TABLE tbl_name DEFAULT CHARACTER SET 'utf8mb4';
-- https://dev.mysql.com/doc/refman/8.0/en/alter-table-examples.html
ALTER TABLE t1 RENAME t2;
ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);
ALTER TABLE t2 ADD d TIMESTAMP;
ALTER TABLE t2 ADD INDEX (d), ADD UNIQUE (a);
ALTER TABLE t2 DROP COLUMN c;
ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (c);
ALTER TABLE t1 TABLESPACE ts_1 STORAGE DISK;
ALTER TABLE t2 STORAGE DISK;
ALTER TABLE t2 TABLESPACE ts_1 STORAGE DISK;
ALTER TABLE t3 MODIFY c2 INT STORAGE MEMORY;
ALTER TABLE t2 ADD id INT AUTO_INCREMENT PRIMARY KEY;
ALTER TABLE t2 RENAME t1;
ALTER TABLE t1 ADD PARTITION (PARTITION p3 VALUES LESS THAN (2002));
ALTER TABLE t1 DROP PARTITION p0, p1;
ALTER TABLE t1 DISCARD PARTITION p2, p3 TABLESPACE;
ALTER TABLE t1 IMPORT PARTITION p2, p3 TABLESPACE;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p1, p3;
ALTER TABLE t2 COALESCE PARTITION 2;
ALTER TABLE t1 ANALYZE PARTITION p1, ANALYZE PARTITION p2;
ALTER TABLE t1 ANALYZE PARTITION p1, CHECK PARTITION p2;
ALTER TABLE t1 ANALYZE PARTITION p1, p2;
ALTER TABLE t1 ANALYZE PARTITION p1;
ALTER TABLE t1 CHECK PARTITION p2;
ALTER TABLE t1 ADD COLUMN c2 INT GENERATED ALWAYS AS (c1 + 1) STORED;
ALTER TABLE t1 MODIFY COLUMN c2 TINYINT GENERATED ALWAYS AS (c1 + 5) STORED;
ALTER TABLE t1 CHANGE c2 c3 INT GENERATED ALWAYS AS (c1 + 1) STORED;
ALTER TABLE t1 DROP COLUMN c3;
ALTER TABLE t1 ADD COLUMN c2 INT GENERATED ALWAYS AS (c1 + 1) STORED;
ALTER TABLE t1 MODIFY COLUMN c2 INT GENERATED ALWAYS AS (c1 + 1) STORED;
ALTER TABLE t1 MODIFY COLUMN c2 INT;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ADD CONSTRAINT c2_positive CHECK (c2 > 0) NOT ENFORCED;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ADD CHECK (c2 > 0) ENFORCED;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ADD CHECK (c2 > 0);
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ALTER c2 SET VISIBLE;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP DEFAULT;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ALGORITHM = INSTANT;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CHECK c2_positive;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ALTER CHECK c2_positive NOT ENFORCED;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ALTER CONSTRAINT c2_positive NOT ENFORCED;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ALTER CONSTRAINT c2_positive ENFORCED;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, ALTER CONSTRAINT c2_positive ENFORCED, ALTER CONSTRAINT c2_positive NOT ENFORCED;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED;
ALTER TABLE your_partitioned_table ADD PARTITION (PARTITION p5 VALUES LESS THAN (2030));
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED ADD PARTITION (PARTITION p5 VALUES LESS THAN (2030)) DROP PARTITION p0;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED DISCARD PARTITION p0 TABLESPACE DISCARD PARTITION ALL TABLESPACE;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED IMPORT PARTITION p0 TABLESPACE IMPORT PARTITION ALL TABLESPACE;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED TRUNCATE PARTITION p0 TRUNCATE PARTITION ALL;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED COALESCE PARTITION 10 COALESCE PARTITION 100;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED REORGANIZE PARTITION p0 INTO (PARTITION p5 VALUES LESS THAN (2030), PARTITION p6 VALUES LESS THAN (2030));
ALTER TABLE t1 ALTER COLUMN c1 SET VISIBLE, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED EXCHANGE PARTITION p0 WITH TABLE t1 WITH VALIDATION;
ALTER TABLE t1 ALTER COLUMN c1 SET VISIBLE, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED EXCHANGE PARTITION p0 WITH TABLE t1 WITHOUT VALIDATION;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED ANALYZE PARTITION p0 ANALYZE PARTITION ALL;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED CHECK PARTITION p0 CHECK PARTITION ALL;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED OPTIMIZE PARTITION p0 OPTIMIZE PARTITION ALL;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED REBUILD PARTITION p0 REBUILD PARTITION ALL;
ALTER TABLE t1 ALTER COLUMN c1 DROP DEFAULT, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED REPAIR PARTITION p0 REPAIR PARTITION ALL;
ALTER TABLE t1 ALTER COLUMN c1 SET VISIBLE, DROP CONSTRAINT c2_positive, ALTER CHECK c2_positive NOT ENFORCED REMOVE PARTITIONING UPGRADE PARTITIONING;

View File

@ -0,0 +1,10 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-table-generated-columns.html
ALTER TABLE t1 ADD COLUMN c2 INT GENERATED ALWAYS AS (c1 + 1) STORED;
ALTER TABLE t1 MODIFY COLUMN c2 TINYINT GENERATED ALWAYS AS (c1 + 5) STORED;
ALTER TABLE t1 CHANGE c2 c3 INT GENERATED ALWAYS AS (c1 + 1) STORED;
ALTER TABLE t1 DROP COLUMN c3;
ALTER TABLE t1 DROP COLUMN c2;
ALTER TABLE t1 MODIFY COLUMN c2 INT GENERATED ALWAYS AS (c1 + 1) STORED;
ALTER TABLE t1 MODIFY COLUMN c2 INT;

View File

@ -0,0 +1,14 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-table-partition-operations.html
ALTER TABLE t1 ADD PARTITION (PARTITION p3 VALUES LESS THAN (2002));
ALTER TABLE t1 DROP PARTITION p0, p1;
ALTER TABLE t1 DISCARD PARTITION p2, p3 TABLESPACE;
ALTER TABLE t1 IMPORT PARTITION p2, p3 TABLESPACE;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p1, p3;
ALTER TABLE t2 COALESCE PARTITION 2;
ALTER TABLE t1 ANALYZE PARTITION p1, ANALYZE PARTITION p2;
ALTER TABLE t1 ANALYZE PARTITION p1, CHECK PARTITION p2;
ALTER TABLE t1 ANALYZE PARTITION p1, p2;
ALTER TABLE t1 ANALYZE PARTITION p1;
ALTER TABLE t1 CHECK PARTITION p2;

View File

@ -0,0 +1,45 @@
-- v5.7: https://dev.mysql.com/doc/refman/5.7/en/alter-tablespace.html
/* ALTER TABLESPACE tablespace_name
{ADD | DROP} DATAFILE 'file_name'
[INITIAL_SIZE [=] size]
[WAIT]
ENGINE [=] engine_name */
ALTER TABLESPACE tablespace_name ADD DATAFILE "file_name" ENGINE 'engine_name';
ALTER TABLESPACE tablespace_name DROP DATAFILE "file_name" ENGINE 'engine_name';
ALTER TABLESPACE tablespace_name DROP DATAFILE "file_name" INITIAL_SIZE = 1G ENGINE 'engine_name';
ALTER TABLESPACE tablespace_name DROP DATAFILE "file_name" INITIAL_SIZE 1G ENGINE 'engine_name';
ALTER TABLESPACE tablespace_name DROP DATAFILE "file_name" INITIAL_SIZE 1G WAIT ENGINE 'engine_name';
ALTER TABLESPACE tablespace_name DROP DATAFILE "file_name" INITIAL_SIZE 1G WAIT ENGINE = 'engine_name';
-- v8: https://dev.mysql.com/doc/refman/8.0/en/alter-tablespace.html
/* ALTER [UNDO] TABLESPACE tablespace_name
NDB only:
{ADD | DROP} DATAFILE 'file_name'
[INITIAL_SIZE [=] size]
[WAIT]
InnoDB and NDB:
[RENAME TO tablespace_name]
InnoDB only:
[AUTOEXTEND_SIZE [=] 'value']
[SET {ACTIVE | INACTIVE}]
[ENCRYPTION [=] {'Y' | 'N'}]
InnoDB and NDB:
[ENGINE [=] engine_name]
Reserved for future use:
[ENGINE_ATTRIBUTE [=] 'string'] */
ALTER UNDO TABLESPACE tablespace_name ADD DATAFILE "file_name" INITIAL_SIZE = 500M WAIT RENAME TO new_tablespace_name AUTOEXTEND_SIZE = 500M SET ACTIVE ENCRYPTION = 'Y' ENGINE 'engine_name' ENGINE_ATTRIBUTE = 'aaa';
ALTER TABLESPACE tablespace_name DROP DATAFILE "file_name" INITIAL_SIZE 500M WAIT AUTOEXTEND_SIZE = 500M SET ACTIVE ENCRYPTION = 'N' ENGINE 'engine_name' ENGINE_ATTRIBUTE = 'aaa';
ALTER TABLESPACE tablespace_name DROP DATAFILE "file_name";

View File

@ -0,0 +1,217 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-user.html
/* ALTER USER [IF EXISTS]
user [auth_option] [, user [auth_option]] ...
[REQUIRE {NONE | tls_option [[AND] tls_option] ...}]
[WITH resource_option [resource_option] ...]
[password_option | lock_option] ...
[COMMENT 'comment_string' | ATTRIBUTE 'json_object']
ALTER USER [IF EXISTS]
USER() user_func_auth_option
ALTER USER [IF EXISTS]
user [registration_option]
ALTER USER [IF EXISTS]
USER() [registration_option]
ALTER USER [IF EXISTS]
user DEFAULT ROLE
{NONE | ALL | role [, role ] ...}
user:
(see Section 6.2.4, Specifying Account Names)
auth_option: {
IDENTIFIED BY 'auth_string'
[REPLACE 'current_auth_string']
[RETAIN CURRENT PASSWORD]
| IDENTIFIED BY RANDOM PASSWORD
[REPLACE 'current_auth_string']
[RETAIN CURRENT PASSWORD]
| IDENTIFIED WITH auth_plugin
| IDENTIFIED WITH auth_plugin BY 'auth_string'
[REPLACE 'current_auth_string']
[RETAIN CURRENT PASSWORD]
| IDENTIFIED WITH auth_plugin BY RANDOM PASSWORD
[REPLACE 'current_auth_string']
[RETAIN CURRENT PASSWORD]
| IDENTIFIED WITH auth_plugin AS 'auth_string'
| DISCARD OLD PASSWORD
| ADD factor factor_auth_option [ADD factor factor_auth_option]
| MODIFY factor factor_auth_option [MODIFY factor factor_auth_option]
| DROP factor [DROP factor]
}
user_func_auth_option: {
IDENTIFIED BY 'auth_string'
[REPLACE 'current_auth_string']
[RETAIN CURRENT PASSWORD]
| DISCARD OLD PASSWORD
}
factor_auth_option: {
IDENTIFIED BY 'auth_string'
| IDENTIFIED BY RANDOM PASSWORD
| IDENTIFIED WITH auth_plugin BY 'auth_string'
| IDENTIFIED WITH auth_plugin BY RANDOM PASSWORD
| IDENTIFIED WITH auth_plugin AS 'auth_string'
}
registration_option: {
factor INITIATE REGISTRATION
| factor FINISH REGISTRATION SET CHALLENGE_RESPONSE AS 'auth_string'
| factor UNREGISTER
}
factor: {2 | 3} FACTOR
tls_option: {
SSL
| X509
| CIPHER 'cipher'
| ISSUER 'issuer'
| SUBJECT 'subject'
}
resource_option: {
MAX_QUERIES_PER_HOUR count
| MAX_UPDATES_PER_HOUR count
| MAX_CONNECTIONS_PER_HOUR count
| MAX_USER_CONNECTIONS count
}
password_option: {
PASSWORD EXPIRE [DEFAULT | NEVER | INTERVAL N DAY]
| PASSWORD HISTORY {DEFAULT | N}
| PASSWORD REUSE INTERVAL {DEFAULT | N DAY}
| PASSWORD REQUIRE CURRENT [DEFAULT | OPTIONAL]
| FAILED_LOGIN_ATTEMPTS N
| PASSWORD_LOCK_TIME {N | UNBOUNDED}
}
lock_option: {
ACCOUNT LOCK
| ACCOUNT UNLOCK
} */
ALTER USER 'jeffrey'@'localhost' IDENTIFIED BY 'new_password' PASSWORD EXPIRE;
ALTER USER 'jeffrey'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'new_password' PASSWORD EXPIRE INTERVAL 180 DAY;
ALTER USER 'jeffrey'@'localhost' ACCOUNT LOCK;
ALTER USER 'jeffrey'@'localhost' ACCOUNT UNLOCK;
ALTER USER 'jeffrey'@'localhost' REQUIRE SSL WITH MAX_CONNECTIONS_PER_HOUR 20;
ALTER USER 'jeffrey'@'localhost' IDENTIFIED BY 'jeffrey_new_password', 'jeanne'@'localhost', 'josh'@'localhost' IDENTIFIED BY 'josh_new_password' REPLACE 'josh_current_password' RETAIN CURRENT PASSWORD REQUIRE SSL WITH MAX_USER_CONNECTIONS 2 PASSWORD HISTORY 5;
ALTER USER 'josh'@'localhost' DISCARD OLD PASSWORD;
ALTER USER 'jeffrey'@'localhost' IDENTIFIED BY 'password';
ALTER USER 'jeffrey'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
ALTER USER 'jeffrey'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password' REPLACE 'current_password';
ALTER USER 'jeffrey'@'localhost' IDENTIFIED BY 'new_password' RETAIN CURRENT PASSWORD;
ALTER USER 'jeffery'@'localhost' DISCARD OLD PASSWORD;
ALTER USER 'jeffrey'@'localhost' IDENTIFIED WITH mysql_native_password AS '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4';
ALTER USER 'user' DROP 2 FACTOR DROP 3 FACTOR;
ALTER USER 'joe'@'10.0.0.1' DEFAULT ROLE administrator, developer;
ALTER USER 'jeffrey'@'localhost' REQUIRE NONE;
ALTER USER 'jeffrey'@'localhost' REQUIRE SSL;
ALTER USER 'jeffrey'@'localhost' REQUIRE X509;
ALTER USER 'jeffrey'@'localhost' REQUIRE ISSUER '/C=SE/ST=Stockholm/L=Stockholm/ O=MySQL/CN=CA/emailAddress=ca@example.com';
ALTER USER 'jeffrey'@'localhost' REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/ O=MySQL demo client certificate/ CN=client/emailAddress=client@example.com';
ALTER USER 'jeffrey'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA';
ALTER USER 'jeffrey'@'localhost' REQUIRE SUBJECT '/C=SE/ST=Stockholm/L=Stockholm/ O=MySQL demo client certificate/ CN=client/emailAddress=client@example.com' AND ISSUER '/C=SE/ST=Stockholm/L=Stockholm/ O=MySQL/CN=CA/emailAddress=ca@example.com' AND CIPHER 'EDH-RSA-DES-CBC3-SHA';
ALTER USER 'jeffrey'@'localhost' WITH MAX_QUERIES_PER_HOUR 500 MAX_UPDATES_PER_HOUR 100;
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE;
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE DEFAULT;
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE NEVER;
ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE INTERVAL 180 DAY;
ALTER USER 'jeffrey'@'localhost' PASSWORD HISTORY DEFAULT;
ALTER USER 'jeffrey'@'localhost' PASSWORD HISTORY 6;
ALTER USER 'jeffrey'@'localhost' PASSWORD REUSE INTERVAL DEFAULT;
ALTER USER 'jeffrey'@'localhost' PASSWORD REUSE INTERVAL 360 DAY;
ALTER USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT;
ALTER USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT OPTIONAL;
ALTER USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT DEFAULT;
ALTER USER 'jeffrey'@'localhost' FAILED_LOGIN_ATTEMPTS 4 PASSWORD_LOCK_TIME 2;
ALTER USER 'bill'@'localhost' ATTRIBUTE '{"baz": "faz", "foo": "moo"}';
ALTER USER 'bill'@'localhost' ATTRIBUTE '{"foo": null}';
ALTER USER 'bill'@'localhost' COMMENT 'Something about Bill';
ALTER USER 'bill'@'localhost' COMMENT '';
ALTER USER 'bill'@'localhost' ATTRIBUTE '{"comment": null}';
ALTER USER IF EXISTS 'user' IDENTIFIED BY 'auth_string' REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED BY 'auth_string' REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED BY 'auth_string' REPLACE 'current_auth_string';
ALTER USER 'user' IDENTIFIED BY 'auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED BY 'auth_string';
ALTER USER IF EXISTS 'user' IDENTIFIED BY RANDOM PASSWORD REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED BY RANDOM PASSWORD REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED BY RANDOM PASSWORD REPLACE 'current_auth_string';
ALTER USER 'user' IDENTIFIED BY RANDOM PASSWORD RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED BY RANDOM PASSWORD;
ALTER USER IF EXISTS 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' REPLACE 'current_auth_string';
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string';
ALTER USER IF EXISTS 'user' IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD REPLACE 'current_auth_string';
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD;
ALTER USER IF EXISTS 'user' IDENTIFIED WITH 'auth_plugin' AS 'auth_string' REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' AS 'auth_string' REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' AS 'auth_string' REPLACE 'current_auth_string';
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' AS 'auth_string' RETAIN CURRENT PASSWORD;
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin' AS 'auth_string';
ALTER USER 'user' IDENTIFIED WITH 'auth_plugin';
ALTER USER USER() DISCARD OLD PASSWORD;
ALTER USER 'user' DISCARD OLD PASSWORD;
ALTER USER IF EXISTS 'user' ADD 2 FACTOR IDENTIFIED BY 'auth_string' ADD 2 FACTOR IDENTIFIED BY 'auth_string';
ALTER USER 'user' ADD 2 FACTOR IDENTIFIED BY 'auth_string' ADD 2 FACTOR IDENTIFIED BY 'auth_string';
ALTER USER 'user' ADD 2 FACTOR IDENTIFIED BY RANDOM PASSWORD;
ALTER USER 'user' ADD 2 FACTOR IDENTIFIED WITH 'auth_plugin' BY 'auth_string';
ALTER USER 'user' ADD 3 FACTOR IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD;
ALTER USER 'user' ADD 3 FACTOR IDENTIFIED WITH 'auth_plugin' AS 'auth_string';
ALTER USER 'user' ADD 3 FACTOR IDENTIFIED WITH 'auth_plugin' AS 'auth_string' ADD 2 FACTOR IDENTIFIED WITH 'auth_plugin' AS 'auth_string';
ALTER USER IF EXISTS 'user' MODIFY 2 FACTOR IDENTIFIED BY 'auth_string' MODIFY 2 FACTOR IDENTIFIED BY 'auth_string';
ALTER USER 'user' MODIFY 2 FACTOR IDENTIFIED BY 'auth_string' MODIFY 2 FACTOR IDENTIFIED BY 'auth_string';
ALTER USER 'user' MODIFY 2 FACTOR IDENTIFIED BY RANDOM PASSWORD;
ALTER USER 'user' MODIFY 2 FACTOR IDENTIFIED WITH 'auth_plugin' BY 'auth_string';
ALTER USER 'user' MODIFY 3 FACTOR IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD;
ALTER USER 'user' MODIFY 3 FACTOR IDENTIFIED WITH 'auth_plugin' AS 'auth_string';
ALTER USER 'user' MODIFY 3 FACTOR IDENTIFIED WITH 'auth_plugin' AS 'auth_string' MODIFY 2 FACTOR IDENTIFIED WITH 'auth_plugin' AS 'auth_string';
ALTER USER 'user' DROP 2 FACTOR DROP 3 FACTOR;
ALTER USER IF EXISTS USER() IDENTIFIED BY 'auth_string';
ALTER USER USER() IDENTIFIED BY 'auth_string' REPLACE 'current_auth_string' RETAIN CURRENT PASSWORD;
ALTER USER USER() IDENTIFIED BY 'auth_string' REPLACE 'current_auth_string';
ALTER USER USER() IDENTIFIED BY 'auth_string' RETAIN CURRENT PASSWORD;
ALTER USER USER() DISCARD OLD PASSWORD;
ALTER USER USER() IDENTIFIED BY 'auth_string';
ALTER USER IF EXISTS 'user' 2 FACTOR INITIATE REGISTRATION;
ALTER USER 'user' 2 FACTOR INITIATE REGISTRATION;
ALTER USER 'user' 3 FACTOR FINISH REGISTRATION SET CHALLENGE_RESPONSE AS 'auth_string';
ALTER USER 'user' 3 FACTOR UNREGISTER;
ALTER USER 'user';
ALTER USER IF EXISTS USER() 2 FACTOR INITIATE REGISTRATION;
ALTER USER USER() 2 FACTOR INITIATE REGISTRATION;
ALTER USER USER() 3 FACTOR FINISH REGISTRATION SET CHALLENGE_RESPONSE AS 'auth_string';
ALTER USER USER() 3 FACTOR UNREGISTER;
ALTER USER USER();
ALTER USER IF EXISTS 'user' DEFAULT ROLE NONE;
ALTER USER 'user' DEFAULT ROLE NONE;
ALTER USER 'user' DEFAULT ROLE ALL;
ALTER USER 'user' DEFAULT ROLE developer;

View File

@ -0,0 +1,22 @@
-- https://dev.mysql.com/doc/refman/8.0/en/alter-view.html
/* ALTER
[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
[DEFINER = user]
[SQL SECURITY { DEFINER | INVOKER }]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION] */
ALTER ALGORITHM = UNDEFINED DEFINER = 'user' SQL SECURITY DEFINER VIEW view_name AS SELECT column1, column2, new_column FROM my_table WHERE condition WITH CASCADED CHECK OPTION;
ALTER ALGORITHM = MERGE DEFINER = 'user' SQL SECURITY DEFINER VIEW view_name AS SELECT column1, column2, new_column FROM my_table WHERE condition WITH CASCADED CHECK OPTION;
ALTER ALGORITHM = TEMPTABLE DEFINER = 'user' SQL SECURITY DEFINER VIEW view_name AS SELECT column1, column2, new_column FROM my_table WHERE condition WITH CASCADED CHECK OPTION;
ALTER ALGORITHM = UNDEFINED DEFINER = 'user' SQL SECURITY INVOKER VIEW view_name AS SELECT column1, column2, new_column FROM my_table WHERE condition WITH CASCADED CHECK OPTION;
ALTER ALGORITHM = MERGE DEFINER = 'user' SQL SECURITY INVOKER VIEW view_name AS SELECT column1, column2, new_column FROM my_table WHERE condition WITH CASCADED CHECK OPTION;
ALTER ALGORITHM = TEMPTABLE DEFINER = 'user' SQL SECURITY INVOKER VIEW view_name AS SELECT column1, column2, new_column FROM my_table WHERE condition WITH CASCADED CHECK OPTION;
ALTER VIEW my_view AS SELECT column1, column2, new_column FROM my_table WHERE condition;
ALTER VIEW my_view AS SELECT column1, column2, new_column FROM my_table;
ALTER VIEW my_view AS SELECT column1, column2 AS new_column FROM my_table;

View File

@ -0,0 +1,48 @@
-- https://dev.mysql.com/doc/refman/8.0/en/analyze-table.html
/* ANALYZE [NO_WRITE_TO_BINLOG | LOCAL]
TABLE tbl_name [, tbl_name] ...
ANALYZE [NO_WRITE_TO_BINLOG | LOCAL]
TABLE tbl_name
UPDATE HISTOGRAM ON col_name [, col_name] ...
[WITH N BUCKETS]
ANALYZE [NO_WRITE_TO_BINLOG | LOCAL]
TABLE tbl_name
UPDATE HISTOGRAM ON col_name [USING DATA 'json_data']
ANALYZE [NO_WRITE_TO_BINLOG | LOCAL]
TABLE tbl_name
DROP HISTOGRAM ON col_name [, col_name] ... */
ANALYZE TABLE t UPDATE HISTOGRAM ON c1, c2, c3 WITH 10 BUCKETS;
ANALYZE TABLE t UPDATE HISTOGRAM ON c1, c3 WITH 10 BUCKETS;
ANALYZE TABLE t DROP HISTOGRAM ON c2;
ANALYZE TABLE t UPDATE HISTOGRAM ON c1;
ANALYZE TABLE t DROP HISTOGRAM ON c1;
ANALYZE TABLE t UPDATE HISTOGRAM ON c1 USING DATA '{"buckets": [[206, 0.0625], [456, 0.125], [608, 0.1875]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "last-updated": "2022-10-11 16:13:14.563319", "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100}';
ANALYZE NO_WRITE_TO_BINLOG TABLE t1, t2, t3;
ANALYZE LOCAL TABLE t1, t2, t3;
ANALYZE TABLE t1, t2, t3;
ANALYZE NO_WRITE_TO_BINLOG TABLE t1 UPDATE HISTOGRAM ON c1, c2, c3 WITH 12 BUCKETS;
ANALYZE NO_WRITE_TO_BINLOG TABLE t1 UPDATE HISTOGRAM ON c1, c2, c3;
ANALYZE NO_WRITE_TO_BINLOG TABLE t1 UPDATE HISTOGRAM ON c1 WITH 13 BUCKETS;
ANALYZE LOCAL TABLE t1 UPDATE HISTOGRAM ON c1, c2, c3;
ANALYZE LOCAL TABLE t1 UPDATE HISTOGRAM ON c1;
ANALYZE LOCAL TABLE t1 UPDATE HISTOGRAM ON c1 WITH 14 BUCKETS;
ANALYZE TABLE t1 UPDATE HISTOGRAM ON c1 WITH 14 BUCKETS;
ANALYZE NO_WRITE_TO_BINLOG TABLE t1 UPDATE HISTOGRAM ON c1 USING DATA '{"buckets": [[206, 0.0625], [456, 0.125], [608, 0.1875]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "last-updated": "2022-10-11 16:13:14.563319", "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100}';
ANALYZE NO_WRITE_TO_BINLOG TABLE t1 UPDATE HISTOGRAM ON c1;
ANALYZE LOCAL TABLE t1 UPDATE HISTOGRAM ON c1 USING DATA '{"buckets": [[206, 0.0625], [456, 0.125], [608, 0.1875]], "data-type": "int", "null-values": 0.0, "collation-id": 8, "last-updated": "2022-10-11 16:13:14.563319", "sampling-rate": 1.0, "histogram-type": "singleton", "number-of-buckets-specified": 100}';
ANALYZE LOCAL TABLE t1 UPDATE HISTOGRAM ON c1;
ANALYZE TABLE t1 UPDATE HISTOGRAM ON c1;
ANALYZE NO_WRITE_TO_BINLOG TABLE t1 DROP HISTOGRAM ON c1, c2, c3;
ANALYZE LOCAL TABLE t1 DROP HISTOGRAM ON c1, c2, c3;
ANALYZE TABLE t1 DROP HISTOGRAM ON c1, c2, c3;

View File

@ -0,0 +1,8 @@
-- https://dev.mysql.com/doc/refman/8.0/en/call.html
/* CALL sp_name([parameter[,...]])
CALL sp_name[()] */
CALL p(@version, @increment);
CALL p;

View File

@ -0,0 +1,89 @@
-- https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html
/* CHANGE MASTER TO option [, option] ... [ channel_option ]
option: {
MASTER_BIND = 'interface_name'
| MASTER_HOST = 'host_name'
| MASTER_USER = 'user_name'
| MASTER_PASSWORD = 'password'
| MASTER_PORT = port_num
| PRIVILEGE_CHECKS_USER = {'account' | NULL}
| REQUIRE_ROW_FORMAT = {0|1}
| REQUIRE_TABLE_PRIMARY_KEY_CHECK = {STREAM | ON | OFF}
| ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = {OFF | LOCAL | uuid}
| MASTER_LOG_FILE = 'source_log_name'
| MASTER_LOG_POS = source_log_pos
| MASTER_AUTO_POSITION = {0|1}
| RELAY_LOG_FILE = 'relay_log_name'
| RELAY_LOG_POS = relay_log_pos
| MASTER_HEARTBEAT_PERIOD = interval
| MASTER_CONNECT_RETRY = interval
| MASTER_RETRY_COUNT = count
| SOURCE_CONNECTION_AUTO_FAILOVER = {0|1}
| MASTER_DELAY = interval
| MASTER_COMPRESSION_ALGORITHMS = 'algorithm[,algorithm][,algorithm]'
| MASTER_ZSTD_COMPRESSION_LEVEL = level
| MASTER_SSL = {0|1}
| MASTER_SSL_CA = 'ca_file_name'
| MASTER_SSL_CAPATH = 'ca_directory_name'
| MASTER_SSL_CERT = 'cert_file_name'
| MASTER_SSL_CRL = 'crl_file_name'
| MASTER_SSL_CRLPATH = 'crl_directory_name'
| MASTER_SSL_KEY = 'key_file_name'
| MASTER_SSL_CIPHER = 'cipher_list'
| MASTER_SSL_VERIFY_SERVER_CERT = {0|1}
| MASTER_TLS_VERSION = 'protocol_list'
| MASTER_TLS_CIPHERSUITES = 'ciphersuite_list'
| MASTER_PUBLIC_KEY_PATH = 'key_file_name'
| GET_MASTER_PUBLIC_KEY = {0|1}
| NETWORK_NAMESPACE = 'namespace'
| IGNORE_SERVER_IDS = (server_id_list),
| GTID_ONLY = {0|1}
}
channel_option:
FOR CHANNEL channel
server_id_list:
[server_id [, server_id] ... ] */
CHANGE MASTER TO MASTER_BIND = 'interface_name', MASTER_HOST = 'host_name' FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_BIND = 'interface_name';
CHANGE MASTER TO MASTER_USER = 'user_name', MASTER_PASSWORD = 'password' FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_PORT = 3011;
CHANGE MASTER TO MASTER_CONNECT_RETRY = 10, MASTER_RETRY_COUNT = 5 FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_DELAY = 10, MASTER_HEARTBEAT_PERIOD = 5 FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_LOG_FILE = 'source_log_name', MASTER_LOG_POS = 4 FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_AUTO_POSITION = 0, MASTER_AUTO_POSITION = 1 FOR CHANNEL 'channel';
CHANGE MASTER TO RELAY_LOG_FILE = 'relay_log_name', RELAY_LOG_POS = 4025, MASTER_SSL = 0, MASTER_SSL = 1 FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_SSL_CA = 'ca_file_name', MASTER_SSL_CAPATH = 'ca_directory_name', MASTER_SSL_CERT = 'cert_file_name' FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_SSL_CRL = 'crl_file_name', MASTER_SSL_CRLPATH = 'crl_directory_name', MASTER_SSL_KEY = 'key_file_name' FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_SSL_CIPHER = 'cipher_list', MASTER_SSL_VERIFY_SERVER_CERT = 0, MASTER_SSL_VERIFY_SERVER_CERT = 1 FOR CHANNEL 'channel';
CHANGE MASTER TO MASTER_TLS_VERSION = 'protocol_list', IGNORE_SERVER_IDS = ('127.0.0.1', '127.0.0.1') FOR CHANNEL 'channel';
CHANGE MASTER TO PRIVILEGE_CHECKS_USER = 'account', PRIVILEGE_CHECKS_USER = NULL, REQUIRE_ROW_FORMAT = 0, REQUIRE_ROW_FORMAT = 1;
CHANGE MASTER TO REQUIRE_TABLE_PRIMARY_KEY_CHECK = STREAM, REQUIRE_TABLE_PRIMARY_KEY_CHECK = ON, REQUIRE_TABLE_PRIMARY_KEY_CHECK = OFF;
CHANGE MASTER TO ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = OFF, ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = LOCAL, ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = '839fa172-9f8d-4bf2-9a13-88dbc6e3814c';
CHANGE MASTER TO SOURCE_CONNECTION_AUTO_FAILOVER = 0, SOURCE_CONNECTION_AUTO_FAILOVER = 1;
CHANGE MASTER TO MASTER_COMPRESSION_ALGORITHMS = 'zlib,zstd', MASTER_COMPRESSION_ALGORITHMS = 'zlib';
CHANGE MASTER TO MASTER_ZSTD_COMPRESSION_LEVEL = 1, MASTER_TLS_CIPHERSUITES = 'ciphersuite_list', MASTER_PUBLIC_KEY_PATH = 'key_file_name';
CHANGE MASTER TO GET_MASTER_PUBLIC_KEY = 0, GET_MASTER_PUBLIC_KEY = 1;
CHANGE MASTER TO NETWORK_NAMESPACE = 'namespace', GTID_ONLY = 0, GTID_ONLY = 1;
CHANGE MASTER TO MASTER_HOST='host1', MASTER_PORT=3002 FOR CHANNEL 'channel2';
CHANGE MASTER TO MASTER_PASSWORD='new3cre';
CHANGE MASTER TO IGNORE_SERVER_IDS = ();
CHANGE MASTER TO
MASTER_HOST='source2.example.com',
MASTER_USER='replication',
MASTER_PASSWORD='password',
MASTER_PORT=3306,
MASTER_LOG_FILE='source2-bin.001',
MASTER_LOG_POS=4,
MASTER_CONNECT_RETRY=10;
CHANGE MASTER TO RELAY_LOG_FILE='replica-relay-bin.006', RELAY_LOG_POS=4025;

View File

@ -0,0 +1,41 @@
-- https://dev.mysql.com/doc/refman/8.0/en/change-replication-filter.html
/* CHANGE REPLICATION FILTER filter[, filter]
[, ...] [FOR CHANNEL channel]
filter: {
REPLICATE_DO_DB = (db_list)
| REPLICATE_IGNORE_DB = (db_list)
| REPLICATE_DO_TABLE = (tbl_list)
| REPLICATE_IGNORE_TABLE = (tbl_list)
| REPLICATE_WILD_DO_TABLE = (wild_tbl_list)
| REPLICATE_WILD_IGNORE_TABLE = (wild_tbl_list)
| REPLICATE_REWRITE_DB = (db_pair_list)
}
db_list:
db_name[, db_name][, ...]
tbl_list:
db_name.table_name[, db_name.table_name][, ...]
wild_tbl_list:
'db_pattern.table_pattern'[, 'db_pattern.table_pattern'][, ...]
db_pair_list:
(db_pair)[, (db_pair)][, ...]
db_pair:
from_db, to_db */
CHANGE REPLICATION FILTER REPLICATE_DO_DB = (d1), REPLICATE_IGNORE_DB = (d2);
CHANGE REPLICATION FILTER REPLICATE_DO_TABLE = (t1), REPLICATE_IGNORE_TABLE = (t2);
CHANGE REPLICATION FILTER REPLICATE_DO_DB = (d1) FOR CHANNEL 'channel_1';
CHANGE REPLICATION FILTER REPLICATE_DO_DB = (db1, db2), REPLICATE_DO_DB = (db3, db4);
CHANGE REPLICATION FILTER REPLICATE_DO_DB = (db3, db4);
CHANGE REPLICATION FILTER REPLICATE_WILD_DO_TABLE = ('db1.old%');
CHANGE REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE = ('db1.new%', 'db2.new%');
CHANGE REPLICATION FILTER REPLICATE_WILD_DO_TABLE = ('db1.old%'), REPLICATE_WILD_IGNORE_TABLE = ('db1.new%', 'db2.new%');
CHANGE REPLICATION FILTER REPLICATE_REWRITE_DB = ((db1, db2));
CHANGE REPLICATION FILTER REPLICATE_REWRITE_DB = ((dbA, dbB), (dbC, dbD));

View File

@ -0,0 +1,58 @@
-- https://dev.mysql.com/doc/refman/8.0/en/change-replication-source-to.html
/* CHANGE REPLICATION SOURCE TO option [, option] ... [ channel_option ]
option: {
SOURCE_BIND = 'interface_name'
| SOURCE_HOST = 'host_name'
| SOURCE_USER = 'user_name'
| SOURCE_PASSWORD = 'password'
| SOURCE_PORT = port_num
| PRIVILEGE_CHECKS_USER = {NULL | 'account'}
| REQUIRE_ROW_FORMAT = {0|1}
| REQUIRE_TABLE_PRIMARY_KEY_CHECK = {STREAM | ON | OFF | GENERATE}
| ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = {OFF | LOCAL | uuid}
| SOURCE_LOG_FILE = 'source_log_name'
| SOURCE_LOG_POS = source_log_pos
| SOURCE_AUTO_POSITION = {0|1}
| RELAY_LOG_FILE = 'relay_log_name'
| RELAY_LOG_POS = relay_log_pos
| SOURCE_HEARTBEAT_PERIOD = interval
| SOURCE_CONNECT_RETRY = interval
| SOURCE_RETRY_COUNT = count
| SOURCE_CONNECTION_AUTO_FAILOVER = {0|1}
| SOURCE_DELAY = interval
| SOURCE_COMPRESSION_ALGORITHMS = 'algorithm[,algorithm][,algorithm]'
| SOURCE_ZSTD_COMPRESSION_LEVEL = level
| SOURCE_SSL = {0|1}
| SOURCE_SSL_CA = 'ca_file_name'
| SOURCE_SSL_CAPATH = 'ca_directory_name'
| SOURCE_SSL_CERT = 'cert_file_name'
| SOURCE_SSL_CRL = 'crl_file_name'
| SOURCE_SSL_CRLPATH = 'crl_directory_name'
| SOURCE_SSL_KEY = 'key_file_name'
| SOURCE_SSL_CIPHER = 'cipher_list'
| SOURCE_SSL_VERIFY_SERVER_CERT = {0|1}
| SOURCE_TLS_VERSION = 'protocol_list'
| SOURCE_TLS_CIPHERSUITES = 'ciphersuite_list'
| SOURCE_PUBLIC_KEY_PATH = 'key_file_name'
| GET_SOURCE_PUBLIC_KEY = {0|1}
| NETWORK_NAMESPACE = 'namespace'
| IGNORE_SERVER_IDS = (server_id_list),
| GTID_ONLY = {0|1}
}
channel_option:
FOR CHANNEL channel
server_id_list:
[server_id [, server_id] ... ] */
CHANGE REPLICATION SOURCE TO SOURCE_BIND = 'interface_name', SOURCE_HOST = 'host_name', SOURCE_USER = 'user_name', SOURCE_PASSWORD = 'password', SOURCE_PORT = 3011, SOURCE_LOG_FILE = 'source_log_name', SOURCE_LOG_POS = 10, RELAY_LOG_FILE = 'relay_log_name', RELAY_LOG_POS = 5, SOURCE_HEARTBEAT_PERIOD = 6, SOURCE_CONNECT_RETRY = 7, SOURCE_RETRY_COUNT = 4, SOURCE_DELAY = 8, SOURCE_COMPRESSION_ALGORITHMS = 'zlib,zstd', SOURCE_ZSTD_COMPRESSION_LEVEL = 11, SOURCE_SSL_CA = 'ca_file_name', SOURCE_SSL_CAPATH = 'ca_directory_name', SOURCE_SSL_CERT = 'cert_file_name', SOURCE_SSL_CRL = 'crl_file_name', SOURCE_SSL_CRLPATH = 'crl_directory_name', SOURCE_SSL_KEY = 'key_file_name', SOURCE_SSL_CIPHER = 'cipher_list', SOURCE_TLS_VERSION = 'protocol_list', SOURCE_TLS_CIPHERSUITES = 'ciphersuite_list', SOURCE_PUBLIC_KEY_PATH = 'key_file_name', NETWORK_NAMESPACE = 'namespace', IGNORE_SERVER_IDS = ('127.0.0.1', '127.0.0.1') FOR CHANNEL 'channel';
CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = NULL, REQUIRE_ROW_FORMAT = 0, REQUIRE_TABLE_PRIMARY_KEY_CHECK = STREAM, ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = OFF, SOURCE_AUTO_POSITION = 0, SOURCE_CONNECTION_AUTO_FAILOVER = 1, SOURCE_SSL = 1, SOURCE_SSL_VERIFY_SERVER_CERT = 0, GET_SOURCE_PUBLIC_KEY = 1, GTID_ONLY = 1 FOR CHANNEL 'channel';
CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = 'account', REQUIRE_ROW_FORMAT = 0, REQUIRE_TABLE_PRIMARY_KEY_CHECK = GENERATE, ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS = LOCAL, SOURCE_AUTO_POSITION = 0, SOURCE_CONNECTION_AUTO_FAILOVER = 1, SOURCE_SSL = 1, SOURCE_SSL_VERIFY_SERVER_CERT = 0, GET_SOURCE_PUBLIC_KEY = 1, GTID_ONLY = 1 FOR CHANNEL 'channel';
CHANGE REPLICATION SOURCE TO SOURCE_HOST='source2.example.com', SOURCE_USER='replication', SOURCE_PASSWORD='password', SOURCE_PORT=3306, SOURCE_LOG_FILE='source2-bin.001', SOURCE_LOG_POS=4, SOURCE_CONNECT_RETRY=10;
CHANGE REPLICATION SOURCE TO SOURCE_HOST='source3.example.com', SOURCE_USER='replication', SOURCE_PASSWORD='password', SOURCE_PORT=3306, SOURCE_AUTO_POSITION = 1 FOR CHANNEL "source_3";
CHANGE REPLICATION SOURCE TO RELAY_LOG_FILE='replica-relay-bin.006', RELAY_LOG_POS=4025;

View File

@ -0,0 +1,9 @@
-- https://dev.mysql.com/doc/refman/8.0/en/checksum-table.html
/* CHECKSUM TABLE tbl_name [, tbl_name] ... [QUICK | EXTENDED] */
CHECKSUM TABLE t1, t2, t3 QUICK;
CHECKSUM TABLE t1, t2, t3 EXTENDED;
CHECKSUM TABLE t1 QUICK;
CHECKSUM TABLE t1 EXTENDED;

View File

@ -0,0 +1,19 @@
-- https://dev.mysql.com/doc/refman/8.0/en/check-table.html
/* CHECK TABLE tbl_name [, tbl_name] ... [option] ...
option: {
FOR UPGRADE
| QUICK
| FAST
| MEDIUM
| EXTENDED
| CHANGED
} */
CHECK TABLE t1, t2, t3 FOR UPGRADE QUICK FAST MEDIUM EXTENDED CHANGED;
CHECK TABLE t1 FOR UPGRADE QUICK FAST MEDIUM EXTENDED CHANGED;
CHECK TABLE t1 FOR UPGRADE QUICK;
CHECK TABLE t1 FAST MEDIUM EXTENDED CHANGED;
CHECK TABLE t1;

View File

@ -0,0 +1,18 @@
-- https://dev.mysql.com/doc/refman/8.0/en/clone.html
/* CLONE clone_action
clone_action: {
LOCAL DATA DIRECTORY [=] 'clone_dir'
| INSTANCE FROM 'user'@'host':port
IDENTIFIED BY 'password'
[DATA DIRECTORY [=] 'clone_dir']
[REQUIRE [NO] SSL]
} */
CLONE LOCAL DATA DIRECTORY = 'clone_dir';
CLONE LOCAL DATA DIRECTORY 'clone_dir';
CLONE INSTANCE FROM root@127.0.0.1:3306 IDENTIFIED BY 'password' DATA DIRECTORY = 'clone_dir' REQUIRE NO SSL;
CLONE INSTANCE FROM root@127.0.0.1:3306 IDENTIFIED BY 'password' REQUIRE SSL;

View File

@ -0,0 +1,48 @@
-- https://dev.mysql.com/doc/refman/8.0/en/commit.html
/* START TRANSACTION
[transaction_characteristic [, transaction_characteristic] ...]
transaction_characteristic: {
WITH CONSISTENT SNAPSHOT
| READ WRITE
| READ ONLY
}
BEGIN [WORK]
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
SET autocommit = {0 | 1} */
START TRANSACTION WITH CONSISTENT SNAPSHOT, WITH CONSISTENT SNAPSHOT;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
START TRANSACTION READ WRITE, READ WRITE;
START TRANSACTION READ WRITE;
START TRANSACTION READ ONLY, READ ONLY;
START TRANSACTION READ ONLY;
START TRANSACTION;
BEGIN WORK;
BEGIN;
COMMIT WORK AND NO CHAIN NO RELEASE;
COMMIT AND NO CHAIN NO RELEASE;
COMMIT WORK AND CHAIN NO RELEASE;
COMMIT AND NO CHAIN RELEASE;
COMMIT AND CHAIN RELEASE;
COMMIT AND CHAIN;
COMMIT NO RELEASE;
COMMIT RELEASE;
ROLLBACK WORK AND NO CHAIN NO RELEASE;
ROLLBACK AND NO CHAIN NO RELEASE;
ROLLBACK WORK AND CHAIN NO RELEASE;
ROLLBACK AND NO CHAIN RELEASE;
ROLLBACK AND CHAIN RELEASE;
ROLLBACK AND CHAIN;
ROLLBACK NO RELEASE;
ROLLBACK RELEASE;
SET autocommit=0;
SET autocommit=1;

View File

@ -0,0 +1,34 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-database.html
/* CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[create_option] ...
create_option: [DEFAULT] {
CHARACTER SET [=] charset_name
| COLLATE [=] collation_name
| ENCRYPTION [=] {'Y' | 'N'}
} */
-- https://dev.mysql.com/doc/refman/5.7/en/create-database.html
/* CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[create_option] ...
create_option: [DEFAULT] {
CHARACTER SET [=] charset_name
| COLLATE [=] collation_name
} */
CREATE DATABASE IF NOT EXISTS db_name;
CREATE DATABASE db_name CHARACTER SET utf8mb4;
CREATE DATABASE db_name COLLATE utf8mb4_unicode_ci;
CREATE DATABASE db_name ENCRYPTION = 'Y';
CREATE DATABASE db_name DEFAULT ENCRYPTION 'N';
CREATE SCHEMA IF NOT EXISTS db_name DEFAULT ENCRYPTION 'Y';
CREATE SCHEMA db_name DEFAULT CHARACTER SET utf8mb4;
CREATE SCHEMA db_name DEFAULT COLLATE utf8mb4_unicode_ci;
CREATE SCHEMA db_name DEFAULT ENCRYPTION = 'Y';
CREATE SCHEMA db_name DEFAULT ENCRYPTION 'N';

View File

@ -0,0 +1,41 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-event.html
/* CREATE
[DEFINER = user]
EVENT
[IF NOT EXISTS]
event_name
ON SCHEDULE schedule
[ON COMPLETION [NOT] PRESERVE]
[ENABLE | DISABLE | DISABLE ON SLAVE]
[COMMENT 'string']
DO event_body
schedule: {
AT timestamp [+ INTERVAL interval] ...
| EVERY interval
[STARTS timestamp [+ INTERVAL interval] ...]
[ENDS timestamp [+ INTERVAL interval] ...]
}
interval:
quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |
WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |
DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND} */
CREATE EVENT IF NOT EXISTS my_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO UPDATE my_schema.my_table SET mycol = mycol + 1;
CREATE EVENT e_totals ON SCHEDULE AT '2006-02-10 23:59:00' DO INSERT INTO test.totals VALUES (NOW());
CREATE EVENT e_hourly ON SCHEDULE EVERY 1 HOUR COMMENT 'Clears out sessions table each hour.' DO DELETE FROM site_activity.sessions;
CREATE EVENT e_daily
ON SCHEDULE
EVERY 1 DAY
COMMENT 'Saves total number of sessions then clears the table each day'
DO INSERT INTO site_activity.totals (time, total)
SELECT CURRENT_TIMESTAMP, COUNT(*)
FROM site_activity.sessions;
CREATE EVENT e_call_my ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY DO CALL myproc(5, 27);

View File

@ -0,0 +1,13 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-function-loadable.html
/* CREATE [AGGREGATE] FUNCTION [IF NOT EXISTS] function_name
RETURNS {STRING|INTEGER|REAL|DECIMAL}
SONAME shared_library_name */
CREATE FUNCTION IF NOT EXISTS my_concat_ws RETURNS STRING SONAME 'udf_my_concat_ws.so';
CREATE FUNCTION my_concat_ws RETURNS INTEGER SONAME 'udf_my_concat_ws.so';
CREATE FUNCTION my_concat_ws RETURNS REAL SONAME 'udf_my_concat_ws.so';
CREATE FUNCTION my_concat_ws RETURNS DECIMAL SONAME 'udf_my_concat_ws.so';
CREATE FUNCTION IF NOT EXISTS my_concat_ws RETURNS DECIMAL SONAME 'udf_my_concat_ws.so';

View File

@ -0,0 +1,43 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-index.html
/* CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX index_name
[index_type]
ON tbl_name (key_part,...)
[index_option]
[algorithm_option | lock_option] ...
key_part: {col_name [(length)] | (expr)} [ASC | DESC]
index_option: {
KEY_BLOCK_SIZE [=] value
| index_type
| WITH PARSER parser_name
| COMMENT 'string'
| {VISIBLE | INVISIBLE}
| ENGINE_ATTRIBUTE [=] 'string'
| SECONDARY_ENGINE_ATTRIBUTE [=] 'string'
}
index_type:
USING {BTREE | HASH}
algorithm_option:
ALGORITHM [=] {DEFAULT | INPLACE | COPY}
lock_option:
LOCK [=] {DEFAULT | NONE | SHARED | EXCLUSIVE}
*/
CREATE UNIQUE INDEX index_name ON table_name (name(10));
CREATE FULLTEXT INDEX index_name ON table_name (name(10));
CREATE SPATIAL INDEX index_name ON table_name (name(10));
CREATE INDEX part_of_name ON customer (name(10));
CREATE INDEX idx1 ON t1 ((col1 + col2));
CREATE INDEX idx2 ON t1 ((col1 + col2), (col1 - col2), col1);
CREATE INDEX id_index ON lookup (id) USING BTREE;
CREATE INDEX id_index ON t1 (id) COMMENT 'MERGE_THRESHOLD=40';
CREATE INDEX i1 ON t1 (c1) ENGINE_ATTRIBUTE='{"key":"value"}';

View File

@ -0,0 +1,30 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-logfile-group.html
/* CREATE LOGFILE GROUP logfile_group
ADD UNDOFILE 'undo_file'
[INITIAL_SIZE [=] initial_size]
[UNDO_BUFFER_SIZE [=] undo_buffer_size]
[REDO_BUFFER_SIZE [=] redo_buffer_size]
[NODEGROUP [=] nodegroup_id]
[WAIT]
[COMMENT [=] 'string']
ENGINE [=] engine_name */
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' INITIAL_SIZE = 10M ENGINE = NDB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' INITIAL_SIZE 10M ENGINE = NDB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' ENGINE = NDB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' UNDO_BUFFER_SIZE = 10M ENGINE = NDB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' UNDO_BUFFER_SIZE 10M ENGINE = NDB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' ENGINE = NDB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' REDO_BUFFER_SIZE = 10M ENGINE = NDB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' REDO_BUFFER_SIZE 10M ENGINE = NDB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' ENGINE = NDB;
CREATE LOGFILE GROUP my_logfile_group ADD UNDOFILE 'undo_1.log' INITIAL_SIZE = 1G UNDO_BUFFER_SIZE = 16M ENGINE INNODB;
CREATE LOGFILE GROUP lg1 ADD UNDOFILE 'undo.dat' INITIAL_SIZE = 10M UNDO_BUFFER_SIZE = 10M REDO_BUFFER_SIZE = 10M NODEGROUP = nodegroup_id WAIT COMMENT = 'logfile' ENGINE = NDB;
CREATE LOGFILE GROUP myg1 ADD UNDOFILE 'myundo-1.dat' ENGINE=NDB;

View File

@ -0,0 +1,23 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-procedure.html
/* CREATE
[DEFINER = user]
PROCEDURE [IF NOT EXISTS] sp_name ([proc_parameter[,...]])
[characteristic ...] routine_body
proc_parameter:
[ IN | OUT | INOUT ] param_name type
characteristic: {
COMMENT 'string'
| LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
} */
CREATE DEFINER = 'admin'@'localhost' PROCEDURE account_count() SQL SECURITY INVOKER SELECT 'Number of accounts:', COUNT(*) FROM mysql.user;
CREATE PROCEDURE AddTwoNumbers(IN a INT, IN b INT) SELECT a + b AS Sum;
CREATE PROCEDURE IF NOT EXISTS AddTwoNumbers(IN a INT, IN b INT) SELECT a + b AS Sum;

View File

@ -0,0 +1,26 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-resource-group.html
/* CREATE RESOURCE GROUP group_name
TYPE = {SYSTEM|USER}
[VCPU [=] vcpu_spec [, vcpu_spec] ...]
[THREAD_PRIORITY [=] N]
[ENABLE|DISABLE]
vcpu_spec: {N | M - N} */
CREATE RESOURCE GROUP group_name TYPE = SYSTEM VCPU = 2, 3 THREAD_PRIORITY = 5 DISABLE;
CREATE RESOURCE GROUP group_name TYPE = SYSTEM VCPU = 2, 3 THREAD_PRIORITY = 5 ENABLE;
CREATE RESOURCE GROUP group_name TYPE = SYSTEM VCPU 2 THREAD_PRIORITY 5 ENABLE;
CREATE RESOURCE GROUP group_name TYPE = SYSTEM VCPU 2 THREAD_PRIORITY 5 ENABLE;
CREATE RESOURCE GROUP group_name TYPE = USER VCPU 2 THREAD_PRIORITY 5 DISABLE;
CREATE RESOURCE GROUP group_name TYPE = USER VCPU 2 THREAD_PRIORITY 5;
CREATE RESOURCE GROUP group_name TYPE = USER VCPU 2 DISABLE;
CREATE RESOURCE GROUP group_name TYPE = USER DISABLE;
CREATE RESOURCE GROUP group_name TYPE = USER ENABLE;
CREATE RESOURCE GROUP group_name TYPE = USER;
CREATE RESOURCE GROUP rg1 TYPE = USER VCPU = 0-63;
CREATE RESOURCE GROUP rg1 TYPE = USER VCPU = 0-63, 64-65, 66;
CREATE RESOURCE GROUP rg2 TYPE = USER THREAD_PRIORITY = 5;
CREATE RESOURCE GROUP rg3 TYPE = USER DISABLE;

View File

@ -0,0 +1,7 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-role.html
/* CREATE ROLE [IF NOT EXISTS] role [, role ] ... */
CREATE ROLE 'admin', 'developer';
CREATE ROLE 'webapp'@'localhost';

View File

@ -0,0 +1,17 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-server.html
/* CREATE SERVER server_name
FOREIGN DATA WRAPPER wrapper_name
OPTIONS (option [, option] ...)
option: {
HOST character-literal
| DATABASE character-literal
| USER character-literal
| PASSWORD character-literal
| SOCKET character-literal
| OWNER character-literal
| PORT numeric-literal
} */
CREATE SERVER server_name FOREIGN DATA WRAPPER mysql OPTIONS (USER 'Remote', HOST '198.51.100.106', DATABASE 'test');

View File

@ -0,0 +1,119 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-table.html
CREATE TEMPORARY TABLE new_tbl SELECT * FROM orig_tbl LIMIT 0;
CREATE TABLE new_tbl LIKE orig_tbl;
CREATE TABLE new_tbl SELECT * FROM orig_tbl LIMIT 0;
CREATE TABLE new_tbl [AS] SELECT * FROM orig_tbl;
CREATE TABLE test (a INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (a), KEY(b)) ENGINE=InnoDB SELECT b,c FROM test2;
CREATE TABLE bar (m INT) SELECT n FROM foo;
CREATE TABLE artists_and_works SELECT artist.name, COUNT(work.artist_id) AS number_of_works FROM artist LEFT JOIN work ON artist.id = work.artist_id GROUP BY artist.id;
CREATE TABLE new_tbl AS SELECT * FROM orig_tbl;
CREATE TABLE t (c CHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin);
CREATE TABLE test (blob_col BLOB, INDEX(blob_col(10)));
CREATE TABLE t1 (c1 INT) ENGINE_ATTRIBUTE='{"key":"value"}';
CREATE TABLE my_table (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
CREATE TABLE t1 (c1 INT STORAGE DISK, c2 INT STORAGE MEMORY) TABLESPACE ts_1 ENGINE NDB;
CREATE TABLE t1 (c1 INT STORAGE MEMORY, c2 INT STORAGE MEMORY) TABLESPACE ts_1 ENGINE NDB;
CREATE TABLE lookup (id INT, INDEX USING BTREE (id)) ENGINE = MEMORY;
CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 VARCHAR(100), c3 VARCHAR(100)) ENGINE=NDB COMMENT="NDB_TABLE=READ_BACKUP=0,PARTITION_BALANCE=FOR_RP_BY_NODE";
CREATE TABLE t1 (col1 INT, col2 CHAR(5)) PARTITION BY HASH(col1);
CREATE TABLE t1 (col1 INT, col2 CHAR(5), col3 DATETIME) PARTITION BY HASH (YEAR(col3));
CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3) PARTITIONS 4;
CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY LINEAR KEY(col3) PARTITIONS 5;
CREATE TABLE t1 (year_col INT, some_data INT) PARTITION BY RANGE (year_col) (
PARTITION p0 VALUES LESS THAN (1991),
PARTITION p1 VALUES LESS THAN (1995),
PARTITION p2 VALUES LESS THAN (1999),
PARTITION p3 VALUES LESS THAN (2002),
PARTITION p4 VALUES LESS THAN (2006),
PARTITION p5 VALUES LESS THAN MAXVALUE
);
CREATE TABLE rc (a INT NOT NULL, b INT NOT NULL) PARTITION BY RANGE COLUMNS(a,b) (
PARTITION p0 VALUES LESS THAN (10,5),
PARTITION p1 VALUES LESS THAN (20,10),
PARTITION p2 VALUES LESS THAN (50,MAXVALUE),
PARTITION p3 VALUES LESS THAN (65,MAXVALUE),
PARTITION p4 VALUES LESS THAN (MAXVALUE,MAXVALUE)
);
CREATE TABLE client_firms (id INT, name VARCHAR(35)) PARTITION BY LIST (id) (
PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21),
PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22),
PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23),
PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24)
);
CREATE TABLE lc (a INT NULL, b INT NULL) PARTITION BY LIST COLUMNS(a,b) (
PARTITION p0 VALUES IN( (0,0), (NULL,NULL) ),
PARTITION p1 VALUES IN( (0,1), (0,2), (0,3), (1,1), (1,2) ),
PARTITION p2 VALUES IN( (1,0), (2,0), (2,1), (3,0), (3,1) ),
PARTITION p3 VALUES IN( (1,3), (2,2), (2,3), (3,2), (3,3) )
);
CREATE TABLE th (id INT, name VARCHAR(30), adate DATE) PARTITION BY LIST(YEAR(adate)) (
PARTITION p1999 VALUES IN (1995, 1999, 2003)
DATA DIRECTORY = '/var/appdata/95/data'
INDEX DIRECTORY = '/var/appdata/95/idx',
PARTITION p2000 VALUES IN (1996, 2000, 2004)
DATA DIRECTORY = '/var/appdata/96/data'
INDEX DIRECTORY = '/var/appdata/96/idx',
PARTITION p2001 VALUES IN (1997, 2001, 2005)
DATA DIRECTORY = '/var/appdata/97/data'
INDEX DIRECTORY = '/var/appdata/97/idx',
PARTITION p2002 VALUES IN (1998, 2002, 2006)
DATA DIRECTORY = '/var/appdata/98/data'
INDEX DIRECTORY = '/var/appdata/98/idx'
);
CREATE TABLE t1 (s1 INT, s2 INT AS (EXP(s1)) STORED) PARTITION BY LIST (s2) (PARTITION p1 VALUES IN (1));
CREATE TABLE foo (a TINYINT NOT NULL) SELECT b+1 AS a FROM bar;
CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE) ENGINE=INNODB;
CREATE TABLE product (category INT NOT NULL, id INT NOT NULL, price DECIMAL, PRIMARY KEY(category, id)) ENGINE=INNODB;
CREATE TABLE customer (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT, product_category INT NOT NULL, product_id INT NOT NULL, customer_id INT NOT NULL, PRIMARY KEY(no), INDEX (product_category, product_id), INDEX (customer_id), FOREIGN KEY (product_category, product_id) REFERENCES product(category, id) ON UPDATE CASCADE ON DELETE RESTRICT, FOREIGN KEY (customer_id) REFERENCES customer(id)) ENGINE=INNODB;
CREATE TABLE t1 (CHECK (c1 <> c2), c1 INT CHECK (c1 > 10), c2 INT CONSTRAINT c2_positive CHECK (c2 > 0), c3 INT CHECK (c3 < 100), CONSTRAINT c1_nonzero CHECK (c1 <> 0), CHECK (c1 > c3));
CREATE TABLE t2 (c1 VARCHAR(10) CHARACTER SET binary, c2 TEXT CHARACTER SET binary, c3 ENUM('a','b','c') CHARACTER SET binary);
CREATE TABLE t3 (c1 VARBINARY(10), c2 BLOB, c3 ENUM('a','b','c') CHARACTER SET binary);
CREATE TABLE triangle (sidea DOUBLE, sideb DOUBLE, sidec DOUBLE AS (SQRT(sidea * sidea + sideb * sideb)));
CREATE VIEW v1 AS SELECT *, CONCAT(first_name,' ',last_name) AS full_name FROM t1;
CREATE TABLE t1 (first_name VARCHAR(10), last_name VARCHAR(10), full_name VARCHAR(255) AS (CONCAT(first_name,' ',last_name)));
CREATE TABLE t1 (c JSON, g INT GENERATED ALWAYS AS (c->"$.id"), INDEX i (g));
CREATE TABLE t2 (a BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c JSON DEFAULT NULL, g INT GENERATED ALWAYS AS (c->"$.id") STORED, INDEX i (g)) ENGINE=NDB;
CREATE TABLE t1 (i INT, j DATE INVISIBLE) ENGINE = InnoDB;
CREATE TABLE t1 (col1 INT, col2 INT INVISIBLE);
CREATE TABLE t2 AS SELECT col1, col2 FROM t1;
CREATE TABLE t2 (col2 INT INVISIBLE) AS SELECT col1, col2 FROM t1;
CREATE TABLE auto_0 (c1 VARCHAR(50), c2 INT);
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b1 BLOB, b2 BLOB COMMENT 'NDB_COLUMN=BLOB_INLINE_SIZE=8000') ENGINE NDB;
CREATE TABLE test.t2 (p INT PRIMARY KEY, c1 BLOB, c2 BLOB COMMENT 'NDB_COLUMN=MAX_BLOB_PART_SIZE') ENGINE NDB;
CREATE TABLE test.t3 (p INT NOT NULL PRIMARY KEY, c1 JSON, c2 JSON COMMENT 'NDB_COLUMN=BLOB_INLINE_SIZE=5000,MAX_BLOB_PART_SIZE') ENGINE NDB;
CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 VARCHAR(100), c3 VARCHAR(100)) ENGINE=NDB
CREATE TABLE t1 (c1 INT PRIMARY KEY) TABLESPACE ts1 ROW_FORMAT=REDUNDANT;
CREATE TABLE t2 (c1 INT PRIMARY KEY) TABLESPACE ts1 ROW_FORMAT=COMPACT;
CREATE TABLE t3 (c1 INT PRIMARY KEY) TABLESPACE ts1 ROW_FORMAT=DYNAMIC;
CREATE TABLE t4 (c1 INT PRIMARY KEY) TABLESPACE ts2 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
CREATE TABLE IF NOT EXISTS tbl_name (CONSTRAINT c2_positive CHECK (c2 > 0) NOT ENFORCED);
CREATE TABLE IF NOT EXISTS tbl_name (CONSTRAINT c2_positive CHECK (c2 > 0) ENFORCED);
CREATE TABLE IF NOT EXISTS tbl_name (CONSTRAINT c2_positive CHECK (c2 > 0));
CREATE TABLE IF NOT EXISTS tbl_name (CONSTRAINT CHECK (c2 > 0) NOT ENFORCED);
CREATE TABLE IF NOT EXISTS tbl_name (CONSTRAINT CHECK (c2 > 0) ENFORCED);
CREATE TABLE IF NOT EXISTS tbl_name (CONSTRAINT CHECK (c2 > 0));
CREATE TABLE IF NOT EXISTS tbl_name (CHECK (c2 > 0) ENFORCED);
CREATE TABLE IF NOT EXISTS tbl_name (CHECK (c2 > 0));

View File

@ -0,0 +1,38 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-tablespace.html
/* CREATE [UNDO] TABLESPACE tablespace_name
InnoDB and NDB:
[ADD DATAFILE 'file_name']
[AUTOEXTEND_SIZE [=] value]
InnoDB only:
[FILE_BLOCK_SIZE = value]
[ENCRYPTION [=] {'Y' | 'N'}]
NDB only:
USE LOGFILE GROUP logfile_group
[EXTENT_SIZE [=] extent_size]
[INITIAL_SIZE [=] initial_size]
[MAX_SIZE [=] max_size]
[NODEGROUP [=] nodegroup_id]
[WAIT]
[COMMENT [=] 'string']
InnoDB and NDB:
[ENGINE [=] engine_name]
Reserved for future use:
[ENGINE_ATTRIBUTE [=] 'string'] */
CREATE TABLESPACE ts1 ADD DATAFILE 'any_directory/../ts1.ibd' AUTOEXTEND_SIZE = 100M;
CREATE TABLESPACE ts1 ENGINE_ATTRIBUTE='{"key":"value"}';
CREATE TABLESPACE `ts1` ADD DATAFILE 'ts1.ibd' ENGINE=INNODB;
CREATE TABLESPACE `ts2` ADD DATAFILE 'ts2.ibd' FILE_BLOCK_SIZE = 8192 Engine=InnoDB;
CREATE TABLESPACE `ts3` ENGINE=INNODB;
CREATE UNDO TABLESPACE 'undo_003' ADD DATAFILE 'undo_003.ibu';

View File

@ -0,0 +1,22 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-trigger.html
/* CREATE
[DEFINER = user]
TRIGGER [IF NOT EXISTS] trigger_name
{ BEFORE | AFTER }
{ INSERT | UPDATE | DELETE }
ON tbl_name FOR EACH ROW
[{ FOLLOWS | PRECEDES } other_trigger_name]
trigger_body
*/
CREATE TRIGGER IF NOT EXISTS my_trigger BEFORE INSERT ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger BEFORE INSERT ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER INSERT ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER UPDATE ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER DELETE ON your_table FOR EACH ROW SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER INSERT ON your_table FOR EACH ROW FOLLOWS other_trigger_name SET NEW.column_name = some_value;
CREATE TRIGGER my_trigger AFTER INSERT ON your_table FOR EACH ROW PRECEDES other_trigger_name SET NEW.column_name = some_value;

View File

@ -0,0 +1,113 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-user.html
/* CREATE USER [IF NOT EXISTS]
user [auth_option] [, user [auth_option]] ...
DEFAULT ROLE role [, role ] ...
[REQUIRE {NONE | tls_option [[AND] tls_option] ...}]
[WITH resource_option [resource_option] ...]
[password_option | lock_option] ...
[COMMENT 'comment_string' | ATTRIBUTE 'json_object']
user:
(see Section 6.2.4, Specifying Account Names)
auth_option: {
IDENTIFIED BY 'auth_string' [AND 2fa_auth_option]
| IDENTIFIED BY RANDOM PASSWORD [AND 2fa_auth_option]
| IDENTIFIED WITH auth_plugin [AND 2fa_auth_option]
| IDENTIFIED WITH auth_plugin BY 'auth_string' [AND 2fa_auth_option]
| IDENTIFIED WITH auth_plugin BY RANDOM PASSWORD [AND 2fa_auth_option]
| IDENTIFIED WITH auth_plugin AS 'auth_string' [AND 2fa_auth_option]
| IDENTIFIED WITH auth_plugin [initial_auth_option]
}
2fa_auth_option: {
IDENTIFIED BY 'auth_string' [AND 3fa_auth_option]
| IDENTIFIED BY RANDOM PASSWORD [AND 3fa_auth_option]
| IDENTIFIED WITH auth_plugin [AND 3fa_auth_option]
| IDENTIFIED WITH auth_plugin BY 'auth_string' [AND 3fa_auth_option]
| IDENTIFIED WITH auth_plugin BY RANDOM PASSWORD [AND 3fa_auth_option]
| IDENTIFIED WITH auth_plugin AS 'auth_string' [AND 3fa_auth_option]
}
3fa_auth_option: {
IDENTIFIED BY 'auth_string'
| IDENTIFIED BY RANDOM PASSWORD
| IDENTIFIED WITH auth_plugin
| IDENTIFIED WITH auth_plugin BY 'auth_string'
| IDENTIFIED WITH auth_plugin BY RANDOM PASSWORD
| IDENTIFIED WITH auth_plugin AS 'auth_string'
}
initial_auth_option: {
INITIAL AUTHENTICATION IDENTIFIED BY {RANDOM PASSWORD | 'auth_string'}
| INITIAL AUTHENTICATION IDENTIFIED WITH auth_plugin AS 'auth_string'
}
tls_option: {
SSL
| X509
| CIPHER 'cipher'
| ISSUER 'issuer'
| SUBJECT 'subject'
}
resource_option: {
MAX_QUERIES_PER_HOUR count
| MAX_UPDATES_PER_HOUR count
| MAX_CONNECTIONS_PER_HOUR count
| MAX_USER_CONNECTIONS count
}
password_option: {
PASSWORD EXPIRE [DEFAULT | NEVER | INTERVAL N DAY]
| PASSWORD HISTORY {DEFAULT | N}
| PASSWORD REUSE INTERVAL {DEFAULT | N DAY}
| PASSWORD REQUIRE CURRENT [DEFAULT | OPTIONAL]
| FAILED_LOGIN_ATTEMPTS N
| PASSWORD_LOCK_TIME {N | UNBOUNDED}
}
lock_option: {
ACCOUNT LOCK
| ACCOUNT UNLOCK
} */
CREATE USER IF NOT EXISTS USER() IDENTIFIED BY 'auth_string' AND IDENTIFIED BY RANDOM PASSWORD AND IDENTIFIED WITH 'auth_plugin' DEFAULT ROLE 'developer';
CREATE USER IF NOT EXISTS 'user' IDENTIFIED BY 'auth_string' AND IDENTIFIED BY RANDOM PASSWORD AND IDENTIFIED WITH 'auth_plugin' DEFAULT ROLE 'developer';
CREATE USER IF NOT EXISTS 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' AND IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD AND IDENTIFIED WITH auth_plugin AS 'auth_string' DEFAULT ROLE 'developer';
CREATE USER IF NOT EXISTS 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' AND IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD AND IDENTIFIED WITH auth_plugin AS 'auth_string', USER() IDENTIFIED WITH 'auth_plugin' BY 'auth_string' AND IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD DEFAULT ROLE 'developer';
CREATE USER IF NOT EXISTS 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' AND IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD AND IDENTIFIED WITH auth_plugin AS 'auth_string', USER() DEFAULT ROLE 'developer';
CREATE USER IF NOT EXISTS 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' AND IDENTIFIED WITH 'auth_plugin' BY RANDOM PASSWORD DEFAULT ROLE 'developer';
CREATE USER IF NOT EXISTS 'user' IDENTIFIED WITH 'auth_plugin' BY 'auth_string' AND IDENTIFIED WITH auth_plugin AS 'auth_string' DEFAULT ROLE 'developer';
CREATE USER IF NOT EXISTS 'user' IDENTIFIED WITH auth_plugin AS 'auth_string' DEFAULT ROLE 'developer';
CREATE USER IF NOT EXISTS 'user' IDENTIFIED WITH auth_plugin AS 'auth_string' DEFAULT ROLE 'developer';
CREATE USER 'user' DEFAULT ROLE 'developer';
CREATE USER USER() IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY RANDOM PASSWORD DEFAULT ROLE 'developer';
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer';
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE NONE;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SUBJECT 'subject' AND CIPHER 'cipher';
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer';
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD EXPIRE DEFAULT;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD EXPIRE NEVER;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD EXPIRE INTERVAL 5 DAY;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD HISTORY DEFAULT;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD HISTORY 5;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD REUSE INTERVAL DEFAULT;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD REUSE INTERVAL 5 DAY;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD REQUIRE CURRENT DEFAULT;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD REQUIRE CURRENT OPTIONAL;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 FAILED_LOGIN_ATTEMPTS 5;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD_LOCK_TIME 5;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 PASSWORD_LOCK_TIME UNBOUNDED;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 ACCOUNT LOCK;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 ACCOUNT UNLOCK;
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 COMMENT 'comment_string';
CREATE USER 'user' IDENTIFIED WITH 'auth_plugin' INITIAL AUTHENTICATION IDENTIFIED BY 'auth_string' DEFAULT ROLE 'developer' REQUIRE SSL AND X509 AND ISSUER 'issuer' WITH MAX_QUERIES_PER_HOUR 1 MAX_UPDATES_PER_HOUR 2 MAX_CONNECTIONS_PER_HOUR 100 MAX_USER_CONNECTIONS 4 ATTRIBUTE 'comment_string';
CREATE USER 'user' IDENTIFIED BY PASSWORD 'auth_string';

View File

@ -0,0 +1,18 @@
-- https://dev.mysql.com/doc/refman/8.0/en/create-view.html
/* CREATE
[OR REPLACE]
[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
[DEFINER = user]
[SQL SECURITY { DEFINER | INVOKER }]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION] */
CREATE VIEW test.v AS SELECT * FROM t;
CREATE VIEW v_today (today) AS SELECT CURRENT_DATE;
CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;
CREATE VIEW v (mycol) AS SELECT 'abc';
CREATE VIEW v AS SELECT * FROM t WHERE t.id = f(t.name);

View File

@ -0,0 +1,44 @@
-- https://dev.mysql.com/doc/refman/8.0/en/delete.html
/* DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [[AS] tbl_alias]
[PARTITION (partition_name [, partition_name] ...)]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
FROM tbl_name[.*] [, tbl_name[.*]] ...
USING table_references
[WHERE where_condition] */
DELETE LOW_PRIORITY QUICK IGNORE FROM some_log AS someLog PARTITION (partition_name, partition_name1) WHERE user = 'cole' ORDER BY timestamp_column LIMIT 1;
DELETE LOW_PRIORITY IGNORE FROM some_log AS someLog PARTITION (partition_name, partition_name1) WHERE user = 'cole' ORDER BY timestamp_column LIMIT 1;
DELETE LOW_PRIORITY QUICK FROM some_log AS someLog PARTITION (partition_name, partition_name1) WHERE user = 'cole' ORDER BY timestamp_column LIMIT 1;
DELETE QUICK IGNORE FROM some_log AS someLog PARTITION (partition_name, partition_name1) WHERE user = 'cole' ORDER BY timestamp_column LIMIT 1;
DELETE LOW_PRIORITY FROM some_log AS someLog PARTITION (partition_name) WHERE user = 'cole' ORDER BY timestamp_column LIMIT 1;
DELETE QUICK FROM some_log AS someLog WHERE user = 'cole' ORDER BY timestamp_column LIMIT 1;
DELETE IGNORE FROM some_log AS someLog PARTITION (partition_name) WHERE user = 'cole' ORDER BY timestamp_column LIMIT 1;
DELETE FROM some_log AS someLog PARTITION (partition_name) WHERE user = 'cole' ORDER BY timestamp_column LIMIT 1;
DELETE FROM tbl_name;
DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.id=t2.id AND t2.id=t3.id;
DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.id=t2.id AND t2.id=t3.id;
DELETE t1 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL;
DELETE a1, a2 FROM t1 AS a1 INNER JOIN t2 AS a2 WHERE a1.id=a2.id;
DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a1.id=a2.id;
DELETE t1, t2 FROM t1 INNER JOIN t2 WHERE a1.id=a2.id;
DELETE FROM t1, t2 USING t1 INNER JOIN t2 WHERE a1.id=a2.id;
DELETE FROM some_log WHERE user = 'cole'

View File

@ -0,0 +1,6 @@
-- https://dev.mysql.com/doc/refman/5.7/en/do.html
-- DO expr [, expr] ...
DO SLEEP(5);

View File

@ -0,0 +1,8 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-database.html
-- DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
DROP DATABASE IF EXISTS db_name;
DROP DATABASE db_name;
DROP SCHEMA IF EXISTS db_name;
DROP SCHEMA db_name;

View File

@ -0,0 +1,7 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-event.html
-- DROP EVENT [IF EXISTS] event_name
DROP EVENT IF EXISTS event_name;
DROP EVENT event_name;

View File

@ -0,0 +1,6 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-function-loadable.html
-- DROP FUNCTION [IF EXISTS] function_name
DROP FUNCTION IF EXISTS function_name;
DROP FUNCTION function_name;

View File

@ -0,0 +1,27 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-index.html
/* DROP INDEX index_name ON tbl_name
[algorithm_option | lock_option] ...
algorithm_option:
ALGORITHM [=] {DEFAULT | INPLACE | COPY}
lock_option:
LOCK [=] {DEFAULT | NONE | SHARED | EXCLUSIVE} */
DROP INDEX `PRIMARY` ON t ALGORITHM = DEFAULT;
DROP INDEX `PRIMARY` ON t ALGORITHM = INPLACE;
DROP INDEX `PRIMARY` ON t ALGORITHM = COPY;
DROP INDEX `PRIMARY` ON t LOCK = DEFAULT;
DROP INDEX `PRIMARY` ON t LOCK = NONE;
DROP INDEX `PRIMARY` ON t LOCK = SHARED;
DROP INDEX `PRIMARY` ON t LOCK = EXCLUSIVE;
DROP INDEX `PRIMARY` ON t ALGORITHM DEFAULT;
DROP INDEX `PRIMARY` ON t ALGORITHM INPLACE;
DROP INDEX `PRIMARY` ON t ALGORITHM COPY;
DROP INDEX `PRIMARY` ON t LOCK DEFAULT;
DROP INDEX `PRIMARY` ON t LOCK NONE;
DROP INDEX `PRIMARY` ON t LOCK SHARED;
DROP INDEX `PRIMARY` ON t LOCK EXCLUSIVE;

View File

@ -0,0 +1,8 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-logfile-group.html
/* DROP LOGFILE GROUP logfile_group
ENGINE [=] engine_name */
DROP LOGFILE GROUP logfile_group ENGINE = engine_name;
DROP LOGFILE GROUP logfile_group ENGINE engine_name;

View File

@ -0,0 +1,8 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-procedure.html
-- DROP {PROCEDURE | FUNCTION} [IF EXISTS] sp_name
DROP PROCEDURE IF EXISTS sp_name;
DROP PROCEDURE sp_name;
DROP FUNCTION IF EXISTS sp_name;
DROP FUNCTION sp_name;

View File

@ -0,0 +1,7 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-resource-group.html
/* DROP RESOURCE GROUP group_name [FORCE] */
DROP RESOURCE GROUP group_name FORCE;
DROP RESOURCE GROUP group_name;

View File

@ -0,0 +1,9 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-role.html
/* DROP ROLE [IF EXISTS] role [, role ] ... */
DROP ROLE IF EXISTS 'developer', 'developer1';
DROP ROLE IF EXISTS 'developer';
DROP ROLE 'developer';
DROP ROLE 'webapp'@'localhost';

View File

@ -0,0 +1,7 @@
-- https://dev.mysql.com/doc/refman/5.7/en/drop-server.html
-- DROP SERVER [ IF EXISTS ] server_name
DROP SERVER IF EXISTS server_name;
DROP SERVER server_name;

View File

@ -0,0 +1,11 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-spatial-reference-system.html
/* DROP SPATIAL REFERENCE SYSTEM
[IF EXISTS]
srid
srid: 32-bit unsigned integer */
DROP SPATIAL REFERENCE SYSTEM IF EXISTS 4120;
DROP SPATIAL REFERENCE SYSTEM 4120;

View File

@ -0,0 +1,17 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-table.html
/* DROP [TEMPORARY] TABLE [IF EXISTS]
tbl_name [, tbl_name] ...
[RESTRICT | CASCADE] */
DROP TEMPORARY TABLE IF EXISTS tbl_name, tbl_name RESTRICT;
DROP TEMPORARY TABLE IF EXISTS tbl_name, tbl_name CASCADE;
DROP TABLE IF EXISTS tbl_name, tbl_name RESTRICT;
DROP TABLE tbl_name, tbl_name RESTRICT;
DROP TABLE IF EXISTS tbl_name, tbl_name CASCADE;
DROP TABLE tbl_name, tbl_name CASCADE;
DROP TABLE IF EXISTS tbl_name RESTRICT;
DROP TABLE tbl_name CASCADE;

View File

@ -0,0 +1,13 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-tablespace.html
/* DROP [UNDO] TABLESPACE tablespace_name
[ENGINE [=] engine_name] */
DROP UNDO TABLESPACE tablespace_name ENGINE = engine_name;
DROP TABLESPACE tablespace_name ENGINE = engine_name;
DROP UNDO TABLESPACE tablespace_name;
DROP UNDO TABLESPACE tablespace_name ENGINE engine_name;
DROP TABLESPACE tablespace_name ENGINE engine_name;
DROP TABLESPACE tablespace_name;

View File

@ -0,0 +1,9 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-trigger.html
-- DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name
DROP TRIGGER IF EXISTS schema_name.trigger_name;
DROP TRIGGER IF EXISTS trigger_name;
DROP TRIGGER schema_name.trigger_name;
DROP TRIGGER trigger_name;

View File

@ -0,0 +1,9 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-user.html
/* DROP USER [IF EXISTS] user [, user] ... */
DROP USER IF EXISTS 'user', 'user1';
DROP USER IF EXISTS 'user';
DROP USER 'user';
DROP USER 'jeffrey'@'localhost';

View File

@ -0,0 +1,12 @@
-- https://dev.mysql.com/doc/refman/8.0/en/drop-view.html
/* DROP VIEW [IF EXISTS]
view_name [, view_name] ...
[RESTRICT | CASCADE] */
DROP VIEW IF EXISTS view_name, view_name1, view_name2 RESTRICT;
DROP VIEW IF EXISTS view_name, view_name1, view_name2 CASCADE;
DROP VIEW view_name, view_name1, view_name2 RESTRICT;
DROP VIEW view_name, view_name1, view_name2 CASCADE;
DROP VIEW view_name RESTRICT;

View File

@ -0,0 +1,100 @@
-- https://dev.mysql.com/doc/refman/8.0/en/grant.html
/* GRANT
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
TO user_or_role [, user_or_role] ...
[WITH GRANT OPTION]
[AS user
[WITH ROLE
DEFAULT
| NONE
| ALL
| ALL EXCEPT role [, role ] ...
| role [, role ] ...
]
]
}
GRANT PROXY ON user_or_role
TO user_or_role [, user_or_role] ...
[WITH GRANT OPTION]
GRANT role [, role] ...
TO user_or_role [, user_or_role] ...
[WITH ADMIN OPTION]
object_type: {
TABLE
| FUNCTION
| PROCEDURE
}
priv_level: {
*
| *.*
| db_name.*
| db_name.tbl_name
| tbl_name
| db_name.routine_name
}
user_or_role: {
user (see Section 6.2.4, Specifying Account Names)
| role (see Section 6.2.5, Specifying Role Names)
} */
GRANT ALL ON db1.* TO 'jeffrey'@'localhost';
GRANT 'role1', 'role2' TO 'user1'@'localhost', 'user2'@'localhost';
GRANT SELECT ON world.* TO 'role3';
GRANT ALL ON db1.* TO 'jeffrey'@'localhost';
GRANT SELECT ON db2.invoice TO 'jeffrey'@'localhost';
CREATE USER u;
GRANT SELECT ON `d_`.* TO u;
GRANT INSERT ON `d%`.* TO u;
GRANT ALL ON test.* TO ''@'localhost';
GRANT SELECT, INSERT ON *.* TO u1;
GRANT SELECT, INSERT, UPDATE ON *.* TO u1;
GRANT ALL ON *.* TO 'some_user'@'some_host';
GRANT SELECT, INSERT ON *.* TO 'some_user'@'some_host';
GRANT ALL ON my_db.* TO 'some_user'@'some_host';
GRANT SELECT, INSERT ON my_db.* TO 'some_user'@'some_host';
GRANT ALL ON my_db.my_tbl TO 'some_user'@'some_host';
GRANT SELECT, INSERT ON my_db.my_tbl TO 'some_user'@'some_host';
GRANT SELECT (col1), INSERT (col1, col2) ON my_db.my_tbl TO 'some_user'@'some_host';
GRANT CREATE ROUTINE ON my_db.* TO 'some_user'@'some_host';
GRANT EXECUTE ON PROCEDURE my_db.my_proc TO 'some_user'@'some_host';
GRANT PROXY ON 'local_user'@'localhost' TO 'external_user'@'some_host';
GRANT 'role1', 'role2' TO 'user1'@'localhost', 'user2'@'localhost';
GRANT 'u1' TO 'u1';
GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO u1;
GRANT INSERT ON schema1.* TO r1;
GRANT SELECT ON schema2.* TO r1;
GRANT r1 TO u1;
GRANT SELECT, INSERT, UPDATE ON *.* TO u2;
GRANT SELECT, INSERT, UPDATE ON *.* TO u3 AS u4;
GRANT SELECT, INSERT, UPDATE ON *.* TO u4 AS u1 WITH ROLE r1;
GRANT USAGE ON *.* TO 'some_user'@'some_host' WITH GRANT OPTION;
GRANT ALL ON db1.t1 TO 'jeffrey'@'localhost' IDENTIFIED BY PASSWORD 'auth_string', 'jeffrey1'@'localhost' IDENTIFIED BY PASSWORD 'auth_string' REQUIRE NONE;
GRANT ALL ON db1.t1 TO 'jeffrey'@'localhost' IDENTIFIED BY PASSWORD 'auth_string', 'jeffrey1'@'localhost' IDENTIFIED BY PASSWORD 'auth_string' REQUIRE CIPHER 'cipher' AND ISSUER 'issuer' SUBJECT 'subject' X509;
GRANT ALL ON db1.t1 TO 'jeffrey'@'localhost' IDENTIFIED BY PASSWORD 'auth_string', 'jeffrey1'@'localhost' IDENTIFIED BY PASSWORD 'auth_string' REQUIRE CIPHER 'cipher' AND ISSUER 'issuer' SUBJECT 'subject' X509 WITH GRANT OPTION;
GRANT ALL ON db1.t1 TO 'jeffrey'@'localhost' IDENTIFIED BY PASSWORD 'auth_string', 'jeffrey1'@'localhost' IDENTIFIED BY PASSWORD 'auth_string' REQUIRE CIPHER 'cipher' AND ISSUER 'issuer' SUBJECT 'subject' X509 WITH MAX_UPDATES_PER_HOUR 100;
GRANT PROXY ON 'user' TO 'user1', 'user2' WITH GRANT OPTION;
GRANT PROXY ON 'user' TO 'user1', 'user2';
GRANT PROXY ON 'user' TO 'user1';
GRANT ALL ON db1.t1 TO 'user' WITH GRANT OPTION AS 'user1' WITH ROLE DEFAULT;
GRANT ALL ON db1.t1 TO 'user' WITH GRANT OPTION AS 'user1' WITH ROLE NONE;
GRANT ALL ON db1.t1 TO 'user' WITH GRANT OPTION AS 'user1' WITH ROLE ALL;
GRANT ALL ON db1.t1 TO 'user' WITH GRANT OPTION AS 'user1' WITH ROLE ALL EXCEPT 'developer';
GRANT ALL ON db1.t1 TO 'user' WITH GRANT OPTION AS 'user1' WITH ROLE 'developer';
GRANT ALL ON TABLE db1.t1 TO 'user' WITH GRANT OPTION AS 'user1' WITH ROLE 'developer';
GRANT ALL ON FUNCTION 'fcName' TO 'user' WITH GRANT OPTION AS 'user1' WITH ROLE 'developer';
GRANT ALL ON PROCEDURE 'name' TO 'user' WITH GRANT OPTION AS 'user1' WITH ROLE 'developer';
GRANT 'developer' TO 'user', 'developer1' WITH ADMIN OPTION;
GRANT 'developer' TO 'user';

View File

@ -0,0 +1,16 @@
-- https://dev.mysql.com/doc/refman/8.0/en/start-group-replication.html
/* START GROUP_REPLICATION
[USER='user_name']
[, PASSWORD='user_pass']
[, DEFAULT_AUTH='plugin_name'] */
START GROUP_REPLICATION USER='user_name', PASSWORD='user_pass', DEFAULT_AUTH='plugin_name';
START GROUP_REPLICATION USER='user_name', PASSWORD='user_pass';
START GROUP_REPLICATION;
-- https://dev.mysql.com/doc/refman/8.0/en/stop-group-replication.html
STOP GROUP_REPLICATION;

View File

@ -0,0 +1,52 @@
-- https://dev.mysql.com/doc/refman/8.0/en/handler.html
/* HANDLER tbl_name OPEN [ [AS] alias]
HANDLER tbl_name READ index_name { = | <= | >= | < | > } (value1,value2,...)
[ WHERE where_condition ] [LIMIT ... ]
HANDLER tbl_name READ index_name { FIRST | NEXT | PREV | LAST }
[ WHERE where_condition ] [LIMIT ... ]
HANDLER tbl_name READ { FIRST | NEXT }
[ WHERE where_condition ] [LIMIT ... ]
HANDLER tbl_name CLOSE */
HANDLER tbl_name OPEN AS tbl_name1;
HANDLER tbl_name OPEN;
HANDLER tbl_name READ index_name = ('value1', 'value2');
HANDLER tbl_name READ index_name = ('value1', 'value2') WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name <= ('value1', 'value2') WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name >= ('value1', 'value2') WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name < ('value1', 'value2') WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name > ('value1', 'value2') WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name = ('value1', 'value2') WHERE name = 'Tony';
HANDLER tbl_name READ index_name <= ('value1', 'value2') WHERE name = 'Tony';
HANDLER tbl_name READ index_name >= ('value1', 'value2') WHERE name = 'Tony';
HANDLER tbl_name READ index_name < ('value1', 'value2') WHERE name = 'Tony';
HANDLER tbl_name READ index_name > ('value1', 'value2') WHERE name = 'Tony';
HANDLER tbl_name READ index_name FIRST WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name NEXT WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name PREV WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name LAST WHERE name = 'Tony' LIMIT 10;
HANDLER tbl_name READ index_name FIRST WHERE name = 'Tony';
HANDLER tbl_name READ index_name NEXT WHERE name = 'Tony';
HANDLER tbl_name READ index_name PREV WHERE name = 'Tony';
HANDLER tbl_name READ index_name LAST WHERE name = 'Tony';
HANDLER tbl_name READ index_name FIRST;
HANDLER tbl_name READ index_name NEXT;
HANDLER tbl_name READ index_name PREV;
HANDLER tbl_name READ index_name LAST;
HANDLER tbl_name READ FIRST;
HANDLER tbl_name READ NEXT;
HANDLER tbl_name CLOSE;

View File

@ -0,0 +1,8 @@
-- https://dev.mysql.com/doc/refman/8.0/en/import-table.html
-- IMPORT TABLE FROM sdi_file [, sdi_file] ...
IMPORT TABLE FROM '/tmp/mysql-files/employees.sdi', '/tmp/mysql-files/managers1.sdi', '/tmp/mysql-files/managers2.sdi';
IMPORT TABLE FROM '/tmp/mysql-files/employees.sdi', '/tmp/mysql-files/managers1.sdi';
IMPORT TABLE FROM '/tmp/mysql-files/*.sdi';

View File

@ -0,0 +1,88 @@
-- https://dev.mysql.com/doc/refman/8.0/en/insert.html
/* INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[(col_name [, col_name] ...)]
{ {VALUES | VALUE} (value_list) [, (value_list)] ... }
[AS row_alias[(col_alias [, col_alias] ...)]]
[ON DUPLICATE KEY UPDATE assignment_list]
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
SET assignment_list
[AS row_alias[(col_alias [, col_alias] ...)]]
[ON DUPLICATE KEY UPDATE assignment_list]
INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[(col_name [, col_name] ...)]
{ SELECT ...
| TABLE table_name
| VALUES row_constructor_list
}
[ON DUPLICATE KEY UPDATE assignment_list]
value:
{expr | DEFAULT}
value_list:
value [, value] ...
row_constructor_list:
ROW(value_list)[, ROW(value_list)][, ...]
assignment:
col_name =
value
| [row_alias.]col_name
| [tbl_name.]col_name
| [row_alias.]col_alias
assignment_list:
assignment [, assignment] ... */
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) VALUES (KW_DEFAULT, KW_DEFAULT), (KW_DEFAULT, KW_DEFAULT) AS row_alias(col_alias, col_alias1) ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) VALUE (KW_DEFAULT, KW_DEFAULT), (KW_DEFAULT, KW_DEFAULT) AS row_alias(col_alias, col_alias1) ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) VALUES (value_list), (value_list1) AS row_alias(col_alias, col_alias1) ON DUPLICATE KEY UPDATE col_name = tbl_name.col_name;
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) VALUES (value_list), (value_list1) AS row_alias(col_alias, col_alias1) ON DUPLICATE KEY UPDATE col_name = 'abc', col_name = tbl_name.col_name;
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) VALUES (value_list), (value_list1) AS row_alias(col_alias) ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) VALUES (value_list), (value_list1) AS row_alias ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) SET col_name = 'abc' AS row_alias(col_alias, col_alias1) ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) SET col_name = 'abc' AS row_alias(col_alias) ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) SET col_name = 'abc', col_name1 = tbl_name.col_name AS row_alias ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) VALUES ROW(1,2,3), ROW(4,5,6), ROW(7,8,9) ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT LOW_PRIORITY IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) TABLE table_name ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT DELAYED IGNORE INTO tbl_name PARTITION (partition_name, partition_name1) (col_name, col_name1) TABLE table_name ON DUPLICATE KEY UPDATE col_name = 'abc';
INSERT INTO tbl_name (col1,col2) VALUES(15,col1*2);
INSERT INTO tbl_name (col1,col2) VALUES(col2*2,15);
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3), (4,5,6), (7,8,9);
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3,4,5,6,7,8,9);
INSERT INTO tbl_name (a,b,c) VALUES ROW(1,2,3), ROW(4,5,6), ROW(7,8,9);
INSERT INTO tbl_temp2 (fld_id) SELECT tbl_temp1.fld_order_id FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
INSERT INTO ta TABLE tb;
INSERT INTO t1 (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6) ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);
INSERT INTO t1 (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=3;
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6) AS new ON DUPLICATE KEY UPDATE c = new.a+new.b;
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6) AS new(m,n,p) ON DUPLICATE KEY UPDATE c = m+n;
INSERT INTO t1 SELECT c, c+d FROM t2 ON DUPLICATE KEY UPDATE b = VALUES(b);
INSERT INTO t1 SELECT * FROM (SELECT c, c+d AS e FROM t2) AS dt ON DUPLICATE KEY UPDATE b = e;
INSERT INTO t1 SET a=1,b=2,c=3 AS new ON DUPLICATE KEY UPDATE c = new.a+new.b;
INSERT INTO t1 SET a=1,b=2,c=3 AS new(m,n,p) ON DUPLICATE KEY UPDATE c = m+n;
INSERT INTO t1 (a, b) SELECT c, d FROM t2 UNION SELECT e, f FROM t3 ON DUPLICATE KEY UPDATE b = b + c;
INSERT INTO t1 (a, b) SELECT * FROM (SELECT c, d FROM t2 UNION SELECT e, f FROM t3) AS dt ON DUPLICATE KEY UPDATE b = b + c;

View File

@ -0,0 +1,35 @@
-- https://dev.mysql.com/doc/refman/8.0/en/insert-select.html
/* INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[(col_name [, col_name] ...)]
{ SELECT ...
| TABLE table_name
| VALUES row_constructor_list
}
[ON DUPLICATE KEY UPDATE assignment_list]
value:
{expr | DEFAULT}
value_list:
value [, value] ...
row_constructor_list:
ROW(value_list)[, ROW(value_list)][, ...]
assignment:
col_name =
value
| [row_alias.]col_name
| [tbl_name.]col_name
| [row_alias.]col_alias
assignment_list:
assignment [, assignment] ... */
INSERT LOW_PRIORITY IGNORE INTO tbl_temp2 (fld_id) SELECT tbl_temp1.fld_order_id FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
INSERT HIGH_PRIORITY IGNORE INTO tbl_temp2 (fld_id) VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8);

View File

@ -0,0 +1,16 @@
-- https://dev.mysql.com/doc/refman/8.0/en/install-component.html
/* INSTALL COMPONENT component_name [, component_name ...
[SET variable = expr [, variable = expr] ...]
variable: {
{GLOBAL | @@GLOBAL.} [component_prefix.]system_var_name
| {PERSIST | @@PERSIST.} [component_prefix.]system_var_name
} */
INSTALL COMPONENT 'file://component1';
INSTALL COMPONENT 'file://component1', 'file://component2';
INSTALL COMPONENT 'file://component1', 'file://component2' SET GLOBAL component1.var1 = 12 + 3, PERSIST component2.var2 = 'strings';
INSTALL COMPONENT 'file://component1', 'file://component2' SET @@GLOBAL.component1.var1 = 12 + 3, @@PERSIST.component2.var2 = 'strings';
INSTALL COMPONENT 'file://component1', 'file://component2' SET PERSIST component1.var1 = 12 + 3, GLOBAL component2.var2 = 'strings';

View File

@ -0,0 +1,6 @@
-- https://dev.mysql.com/doc/refman/8.0/en/install-plugin.html
/* INSTALL PLUGIN plugin_name SONAME 'shared_library_name' */
INSTALL PLUGIN plugin_name SONAME 'shared_library_name';

View File

@ -0,0 +1,12 @@
-- https://dev.mysql.com/doc/refman/5.7/en/intersect.html
/* query_expression_body INTERSECT [ALL | DISTINCT] query_expression_body
[INTERSECT [ALL | DISTINCT] query_expression_body]
[...]
query_expression_body:
See Section 13.2.14, Set Operations with UNION, INTERSECT, and EXCEPT */
(SELECT * FROM table_name1) INTERSECT (SELECT * FROM table_name2);
SELECT column_list FROM table_a WHERE age = 12 INTERSECT SELECT column1, COUNT(column2) FROM table_name GROUP BY column1;

View File

@ -0,0 +1,40 @@
-- https://dev.mysql.com/doc/refman/8.0/en/load-data.html
/* LOAD DATA
[LOW_PRIORITY | CONCURRENT] [LOCAL]
INFILE 'file_name'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[CHARACTER SET charset_name]
[{FIELDS | COLUMNS}
[TERMINATED BY 'string']
[[OPTIONALLY] ENCLOSED BY 'char']
[ESCAPED BY 'char']
]
[LINES
[STARTING BY 'string']
[TERMINATED BY 'string']
]
[IGNORE number {LINES | ROWS}]
[(col_name_or_user_var
[, col_name_or_user_var] ...)]
[SET col_name={expr | DEFAULT}
[, col_name={expr | DEFAULT}] ...] */
LOAD DATA LOW_PRIORITY LOCAL INFILE 'data.txt' REPLACE INTO TABLE db2.my_table PARTITION (partition_name, partition_name1) CHARACTER SET utf8mb4 COLUMNS TERMINATED BY ',' OPTIONALLY ENCLOSED BY 'char' ESCAPED BY 'char' LINES STARTING BY 'xxx' TERMINATED BY ',' IGNORE 1 ROWS (col_name_or_user_var) SET column2 = @var1/100;
LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx';
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test IGNORE 1 LINES;
LOAD DATA INFILE 'data.txt' INTO TABLE table2 FIELDS TERMINATED BY ',';
LOAD DATA INFILE 'data.txt' INTO TABLE table2 FIELDS TERMINATED BY '\t';
LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES;
LOAD DATA INFILE '/tmp/jokes.txt' INTO TABLE jokes FIELDS TERMINATED BY '' LINES TERMINATED BY '\n%%\n' (joke);
LOAD DATA INFILE 'person_data.txt' INTO TABLE person_data;
LOAD DATA INFILE 'person_data.txt' INTO TABLE person_data (col_name_or_user_var, col_name_or_user_var1);
LOAD DATA INFILE 'file.txt' INTO TABLE t1 (column1, @var1) SET column2 = @var1/100;
LOAD DATA INFILE 'file.txt' INTO TABLE t1 (column1, column2) SET column3 = CURRENT_TIMESTAMP;
LOAD DATA INFILE 'file.txt' INTO TABLE t1 (column1, @dummy, column2, @dummy, column3);
LOAD DATA INFILE '/tmp/bit_test.txt' INTO TABLE bit_test (@var1) SET b = CAST(CONV(MID(@var1, 3, LENGTH(@var1)-3), 2, 10) AS UNSIGNED);

View File

@ -0,0 +1,29 @@
-- https://dev.mysql.com/doc/refman/8.0/en/load-xml.html
/* LOAD XML
[LOW_PRIORITY | CONCURRENT] [LOCAL]
INFILE 'file_name'
[REPLACE | IGNORE]
INTO TABLE [db_name.]tbl_name
[CHARACTER SET charset_name]
[ROWS IDENTIFIED BY '<tagname>']
[IGNORE number {LINES | ROWS}]
[(field_name_or_user_var
[, field_name_or_user_var] ...)]
[SET col_name={expr | DEFAULT}
[, col_name={expr | DEFAULT}] ...] */
LOAD XML LOW_PRIORITY LOCAL INFILE 'person.xml' REPLACE INTO TABLE db_name.person CHARACTER SET utf8mb4 ROWS IDENTIFIED BY '<person>' IGNORE 1 LINES (field_name_or_user_var, field_name_or_user_var1) SET column2 = @var1/100;
LOAD XML CONCURRENT INFILE 'person.xml' IGNORE INTO TABLE db_name.person CHARACTER SET utf8mb4 ROWS IDENTIFIED BY '<person>' IGNORE 1 ROWS (field_name_or_user_var, field_name_or_user_var1) SET column2 = @var1/100;
LOAD XML LOCAL INFILE 'person.xml' INTO TABLE db_name.person ROWS IDENTIFIED BY '<person>';
LOAD XML LOCAL INFILE 'person-dump.xml' INTO TABLE person2;
LOAD XML INFILE '../bin/person-dump.xml' INTO TABLE test.individual;
(SELECT 1 AS result UNION SELECT 2)
ORDER BY result DESC LIMIT 1 OFFSET 1;

View File

@ -0,0 +1,25 @@
-- https://dev.mysql.com/doc/refman/8.0/en/lock-instance-for-backup.html
/* LOCK TABLES
tbl_name [[AS] alias] lock_type
[, tbl_name [[AS] alias] lock_type] ...
lock_type: {
READ [LOCAL]
| [LOW_PRIORITY] WRITE
}
UNLOCK TABLES */
LOCK TABLES t1 READ;
LOCK TABLE t WRITE, t AS t1 READ;
LOCK TABLE t READ;
LOCK TABLE t READ LOCAL;
LOCK TABLE t AS my_alias READ;
LOCK TABLES t1 WRITE, t2 READ;
LOCK TABLES trans READ, customer LOW_PRIORITY WRITE;
LOCK TABLES trans READ, customer WRITE;
UNLOCK TABLES;

View File

@ -0,0 +1,13 @@
-- https://dev.mysql.com/doc/refman/8.0/en/optimize-table.html
/* OPTIMIZE [NO_WRITE_TO_BINLOG | LOCAL]
TABLE tbl_name [, tbl_name] ... */
OPTIMIZE NO_WRITE_TO_BINLOG TABLE t1, t2, t3;
OPTIMIZE LOCAL TABLE t1, t2, t3;
OPTIMIZE TABLE t1, t2, t3;
OPTIMIZE NO_WRITE_TO_BINLOG TABLE t1;
OPTIMIZE LOCAL TABLE t1;
OPTIMIZE TABLE t1;

Some files were not shown because too many files have changed in this diff Show More