Minifier SQL

Supprime le formatage superflu ; la sortie reste du texte, pas un fichier compressé.

Entrée: TexteRésultat: Texte

Saisie de texte

Exemples

Compact a three-row INSERT statement

Entrée

INSERT INTO planets (name, moons)
VALUES ('Earth', 1),
       ('Mars', 2),
       ('Venus', 0);

Expected answer

INSERT INTO planets(name, moons) VALUES ('Earth', 1), ('Mars', 2), ('Venus', 0);
Reduce whitespace around an EXISTS subquery

Entrée

SELECT name
FROM customers
WHERE EXISTS (SELECT 1 FROM orders WHERE orders.customer_id = customers.id);

Expected answer

SELECT name FROM customers WHERE EXISTS(SELECT 1 FROM orders WHERE orders.customer_id = customers.id);
Keep a spaced city name inside a string literal

Entrée

SELECT station_id, city
FROM stations
WHERE city = 'New York'
ORDER BY station_id;

Expected answer

SELECT station_id, city FROM stations WHERE city = 'New York' ORDER BY station_id;
Compact an update with an explicit safety condition

Entrée

UPDATE inventory
SET stock = stock - 1
WHERE sku = 'BOOK-ALICE' AND stock > 0;

Expected answer

UPDATE inventory SET stock = stock - 1 WHERE sku = 'BOOK-ALICE' AND stock > 0;
Keep UNION ALL when combining two event streams

Entrée

SELECT occurred_at, 'signup' AS kind FROM signups
UNION ALL
SELECT occurred_at, 'purchase' AS kind FROM purchases;

Expected answer

SELECT occurred_at, 'signup' AS kind FROM signups UNION ALL SELECT occurred_at, 'purchase' AS kind FROM purchases;

Outils associés

Nettoyage du code

Référence de l’opération

Voir la documentation technique originale (English)