MySQL triggers alteration - sql

Is there any way how to update automatically mysql trigger(s) structure, every time when I alter a table?

No - any alteration that impacts the trigger requires you to update separately from the ALTER TABLE statement.

Related

ALTER COLUMN WITHOUT DROP

I want to alter column within the table to be NULL from NOT NULL.
The problem is that table has one constraint, one trigger and 4 indexes.
Can I somehow alter that column without dropping and recreating everything?
exec sys.sp_depends 'object_name'
List all dependencies and then drop them an recreate everything.
SQL Managements studio offer option with SCRIPT AS CREATE and you can save all views, triggers, tables as backup...

How do I get the performed operation and affected table from a database trigger in oracle?

How do I get the performed operation and affected table from a database trigger in oracle?
I want to create a trigger for a schema in Oracle which gets executed on drop or alter or create on database So I need something similar like inserting, updating, deleting but for DDL statements, and somehow I need to know the affected table and schema.
The documentation has a list of the event attribute functions that you can access. It looks like you'd want ora_sysevent for the event along with ora_dict_obj_name and ora_dict_obj_owner to identify the object in question.

Difference between Alter and Update SQL

I am busy studying MySQL and I understand that update is used to update a record or row in a table. So what does alter do that is so different? Seems like they are the same.
Thanks, any help will be appreciated.
ALTER is a DDL (Data Definition Language) statement. Whereas UPDATE is a DML (Data Manipulation Language) statement. ALTER is used to update the structure of the table (add/remove field/index etc). Whereas UPDATE is used to update data.
The ALTER changes the table in the database, you can add or remove columns, etc. But it does not change data (except in the dropped or added columns of course).
While the UPDATE changes the rows in the table, and leaves the table unchanged.
ALTER is used to change things like table structures or stored procs, otherwise known as DDL statements.
ALTER table MyTable
ADD MyNewColumn VARCHAR(100)
OR
ALTER PROC dbo.MyStoredProc
Alter command is a data definition language
Update command is a data manipulation language
Alter example- table structure, table name, sp, functions
Update example-change database in a row or column etc
Alter command make changes in table structure.
Update command make changes with inside the table
Alter command is used to add, delete modify the attributes of the table in the database
Update command is used to update existing record in a database
Let's see in simple words...
Alter command we use for the modify the structure of the database, table(add, drop, modify)and it falls under DDL.
Update command we use for the modify the rows(records) of the table using where condition and its fall under DML.

ALTER SQL statement takes very much time

We are facing problem in the alter table SQL statement. Some time we update our database at client side and the alter table sql taking very much time. I like to know, how alter works? Does alter statement performance correlated to that table data? Means, if table have large data then alter will take much time.
There is also problem with the Oracle 11G R2. Is there any changes which need to incorporate to our code? Our code is very old and working fine till now?
There could be several reasons for this:
If the table is locked by another
query/resource. It would wait for the
lock to be released and then execute
the update...
If the table contains many rows and you have added a new column in the table with a default value, it would execute an update query for whole table after altering the table to update all the existing records with the default value...
If for example you add a new column with a default value in a large table, then it will take time depending the size of the table.

SQL trigger on Truncate

How to Fire a trigger when you do TRUNCATE (instead deleted) in MSSQL
From msdn:
TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions.
You can't do this on SQL server.
From MSDN
TRUNCATE TABLE cannot activate a
trigger because the operation does not
log individual row deletions. For more
information, see CREATE TRIGGER
(Transact-SQL).
Are you letting users run TRUNCATE TABLE ad hoc / willy nilly? If not, instead of worrying about using a trigger, why not wrap the TRUNCATE command in a stored procedure that also deals with whatever the trigger would have done after the truncate finished? (But you'd have to do it in the opposite order, of course.)