Toolkit DEV

Data Definition Language

  • Créer une base de données (un schéma)

CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name

  • Supprimer une base de données (un schéma)

DROP {DATABASE | SCHEMA} [IF EXISTS] db_name

  • Créer une table

CREATE TABLE [IF NOT EXISTS] tbl_name
(create_definition,…)
[table_option] …

  • Modifier la structure d’une table

ALTER TABLE tbl_name
alter_specification [, alter_specification] …

  • Supprimer une table

DROP TABLE [IF EXISTS]
tbl_name

  • Vider une table

TRUNCATE [TABLE] tbl_name



Data Manipulation Language

  • Lire les données d’une table

SELECT select_expr, …
[FROM table_references
[WHERE where_condition]
[GROUP BY {col_name}
[HAVING where_condition]
[ORDER BY {col_name}  [ASC | DESC], …]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]

  • Insérer des données dans une table

INSERT [INTO] tbl_name [(col_name,…)]  {VALUES} ({expr},…),(…),…

  • Modifier les données d’une table

UPDATE tbl_name
SET col_name1={expr1} [, col_name2={expr2}] …
[WHERE where_condition]

  • Effacer les données d’une table

DELETE FROM tbl_name
[WHERE where_condition]

  • Remplacer un enregistrement

REPLACE [INTO] tbl_name [(col_name,…)] {VALUES } ({expr},…),(…),…

  • Importer des données dans une table

LOAD DATA INFILE ‘file_name’
[REPLACE | IGNORE]
INTO TABLE tbl_name
[{FIELDS} [TERMINATED BY ‘string’]
[ ENCLOSED BY ‘char’]
]
[LINES
[STARTING BY ‘string’]
[TERMINATED BY ‘string’]
]
[IGNORE number LINES]
[(col_name_or_user_var,…)]
[SET col_name = expr,…]



Transaction Control Language

  • Démarrer une transaction

START TRANSACTION

  • Valider une transaction

COMMIT

  • Annuler une transaction

ROLLBACK

  • Paramétrer le niveau d' »auto validation » (autocommit)

SET autocommit = {0 | 1}