Sql
De Linuxmemo.
(Différences entre les versions)
(→Opérateur de comparaison dabs la clause WHERE) |
|||
| Ligne 48 : | Ligne 48 : | ||
select NAME,VERSION,PUBLISHER from ocsweb.softwares where NAME LIKE "%firefox%"; | select NAME,VERSION,PUBLISHER from ocsweb.softwares where NAME LIKE "%firefox%"; | ||
SELECT COUNT(*) FROM foo WHERE bar NOT LIKE '%baz%' OR bar IS NULL; | SELECT COUNT(*) FROM foo WHERE bar NOT LIKE '%baz%' OR bar IS NULL; | ||
| + | |||
| + | ==Transaction SQL== | ||
| + | START TRANSACTION, COMMIT, and ROLLBACK Syntax | ||
| + | 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} | ||
==Références== | ==Références== | ||
Version du 7 septembre 2018 à 09:14
Structured Query Language
Sommaire |
Astuces
- ajouter un utilisateur:
GRANT ALL PRIVILEGES ON base.* TO 'user'@'localhost' IDENTIFIED BY 'un_mot_de_passe' WITH GRANT OPTION;
- recharger les droits:
FLUSH PRIVILEGES;
Facultatif:
GRANT RELOAD,PROCESS ON *.* TO 'user'@'localhost'; GRANT USAGE ON *.* TO 'user'@'localhost';
- voir les droits pour un utilisateur
SHOW GRANTS FOR 'user'@'localhost';
- Commentaire
-- pour une ligne
/* caractère de début pour plusieurs ligne */ caractère de fin
Jointures
Exemple: Metasploit#DB_Postgres_jointures
Opérateur de comparaison dabs la clause WHERE
= (Égal à) > (Supérieur à) < (Inférieur à) >= (Supérieur ou égal à) <= (Inférieur ou égal à) <> (Différent de) != (Différent de) !< (Non inférieur à) !> (Non supérieur à) BETWEEN Between an inclusive range LIKE Search for a pattern IN To specify multiple possible values for a column
avec like '%' = Chaîne de caractères '_' = Un seul caractère select NAME,VERSION,PUBLISHER from ocsweb.softwares where NAME LIKE "%firefox%"; SELECT COUNT(*) FROM foo WHERE bar NOT LIKE '%baz%' OR bar IS NULL;
Transaction SQL
START TRANSACTION, COMMIT, and ROLLBACK Syntax
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}
Références
- Référence absolues: base.table.colonne
- Référence relative (apres selection de la base): table.colonne