Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create triggers in Data Grip?

I want to create triggers in my table.I am using Data Grip as an interface to connect to my database.I googled around and the documentation said that it had something like a "Generate" drop down list which has something like function and procedures templates available for creation.But I get no such drop down list and even when I go to the new option after right clicking a table,I don't get an option for functions or procedures. I am using DataGrip 2017.1.2 and a MySQL data source.

like image 697
Shankha057 Avatar asked Apr 28 '17 06:04

Shankha057


People also ask

How can I see triggers in DataGrip?

Open Database from View -> Tool Windows or push Alt + 1 key shotcut. Now in opened explorer expand [your database] -> [your schema] -> tables -> [your table] branches and look for table triggers - elements with blue thunder icon.


2 Answers

As an alternative to @Andrew 's answer (since 2016.3 or .2), you can:

  • Open database console
  • Press Alt+Ins (Cmd+N on Mac)
  • "Generate" menu will pop up
  • Select "Trigger"
  • A "live template" will start
  • Type trigger name...Enter
  • Type table name...Enter
  • ...
  • Execute resulting script with Ctrl+Enter
like image 144
kassak Avatar answered Oct 19 '22 09:10

kassak


If nothing else, you could begin writing a CREATE TRIGGER statement and let DataGrip's code completion help you along the way.

In DataGrip, either Open Console (Ctrl+Shift+F10), or right-click your table name and choose New > Console File, to open a window where you can begin typing "CREATE TRIGGER", and go from there.

The 23.3 Using Triggers page in the MySQL manual and its 23.3.1 Trigger Syntax and Examples linked page are useful references.

like image 20
Andrew Avatar answered Oct 19 '22 08:10

Andrew