How to comment & uncomment multiple line SQL code in DataGrip IDE

user4547600 picture user4547600 · Apr 3, 2019 · Viewed 10.3k times · Source

I would like to comment out queries with a keyboard shortcut, like so

 SELECT * 
   FROM Academics
   WHERE Academic_id = 1

To become

--SELECT * 
   --FROM Academics
   --WHERE Academic_id = 1

Answer

Kemal Cholovich picture Kemal Cholovich · Apr 3, 2019
  1. Select SQL code

    SELECT TOP 3 * FROM CUSTOMER WHERE Customerid ='4de3092d03b742f3b2b88cf6fe0b09d0'

  2. Press CTRL+/ (or CMD+/ on Mac) on the keyboard

  3. Code will be commented

    --SELECT TOP 3 * --FROM CUSTOMER --WHERE Customerid ='4de3092d03b742f3b2b88cf6fe0b09d0'

  4. If you need to uncomment it, you need to mark commented code and press the same keyboard combination CTRL+/ (or CMD+/ on Mac) on the keyboard Code will become uncommented again:

    SELECT TOP 3 * FROM CUSTOMER WHERE Customerid ='4de3092d03b742f3b2b88cf6fe0b09d0'