Can we run the SQL dump command through a stored procedure/Trigger. I have to create a database on fly when certain events happen in the table.
I have achieved it on mysql command prompt or by workbench, however need a way to do it through procedure or trigger.
Related
I execute the following statement from the cmd terminal to import my MySQL Database:
mysql u- root p- database < "C:\Users\Tom\data.sql"
When I open my MySQL Database from the MySQL Workbench I've realised that more tables have been created that I don't recognise. Basically, what is happening is the stored procedures/routines I have created seem to be automatically running and thus creating many more tables? I don't want this, I'd rather execute routines as I wish using the "Call" statements in MySQL, is there a way stop this happening?
I have 3 triggers in mysql. Is there a way to create sequence on running the triggers like sql server?
How can I run a stored procedure at server start-up? Is this possible?
I just want to run a SQL query.
You can use the init-file variable in your configuration file to run a text file containing SQL statements in it.
I created a database then I create a procedure. When I want to alter this database, I got an error while altering this database says:
create/alter must be the first statement in a query batch
If you have more than one statement to run use 'GO' command:
alter database xyz ...
GO
INSERT INTO myTable() ...
GO
etc
I found tutorials on creating a stored procedures on the net, I just don't understand when exactly do I need to execute the creation of the stored procedure.
do the stored procedures creation should be executed each time i restart my MySQL server ?
do I need to execute the stored procedures creation sql each time I start my application?
Stored procedures are persisted to the database, ie they will be there even after a restart of the database server. You create them once and then you run them as often as you need. Of course you may want to change them sometimes using an alter statement.