The issue about SQL statements that use triggers to delete tables

Updated on technology 2024-02-09
13 answers
  1. Anonymous users2024-02-05

    In the case of sqlserver, you can write a database-based trigger in which you can get the name of the table to be operated on, and sqlserver prohibits the user from deleting the specified table.

    If in doubt, communicate in a timely manner!

  2. Anonymous users2024-02-04

    This can be controlled by setting the user's operation permissions on the table.

  3. Anonymous users2024-02-03

    create trigger t1 on reader instead of delete as

    delete borrowing where reader number = (select reader number from deleted).

  4. Anonymous users2024-02-02

    create trigger a_del

    on [reader] for delete

    as--set nocount on

    delete e

    from [Reader] e

    inner join deleted [borrowing] on e.[Reader Number] = [Borrowing].[Reader Number].

  5. Anonymous users2024-02-01

    Needless to say, it's just what kind of mechanism to use to implement it.

    1. The trigger is only executed when the data is updated;

    2. However, if you delete data, it is generally a scheduled job;

  6. Anonymous users2024-01-31

    This is not a facilitator, you have to use a scheduler and let it run automatically every day.

  7. Anonymous users2024-01-30

    This type of statement is available in later SQL versions.

    create trigger trigger name.

    on database

    for drop_tableas

  8. Anonymous users2024-01-29

    This trigger can be written like this, when someone deletes the data in table A, just execute a statement that will report an error.

  9. Anonymous users2024-01-28

    No value was assigned to @plane seat.

    in storage.

    while.

    Insert "select

    plane_seat

    plane_seat

    frominserted”

  10. Anonymous users2024-01-27

    ***table a***

    create table [dbo].[test_a](

    id_a] [nchar](10) null,col1] [nchar](10) null,col2] [nchar](10) null,col3] [nchar](10) null

    on [primary]

    **table b***

    create table [dbo].[test_b](

    id_b] [nchar](10) null,col1] [nchar](10) null,col2] [nchar](10) null,col3] [nchar](10) null

    on [primary]

    **create trigger***

    create trigger [dbo].[tri_test]

    on [dbo].[test_a]

    after delete

    asdelete from test_b where id_b in (select id_a from deleted)

    The ID of table A corresponds to the ID of table B

    When you delete data in table A, the IDs associated with table B are also deleted.

    In addition, foreign keys can achieve the same effect, and if the logic is relatively simple, foreign keys can be used.

  11. Anonymous users2024-01-26

    Let the two table associated fields be:

    The id** is as follows:

    create trigger trnameon The name of the source table.

    for delete

    asdelete from destination table name where exists(select 1 from deleted where destination table name. id)

  12. Anonymous users2024-01-25

    It's okay to write a trigger.,How to write it, you just look at the help of SQL.,I didn't give anything.,I can't write it to you.。

  13. Anonymous users2024-01-24

    What do you need to ask?

Related questions
5 answers2024-02-09

F get domain contrast is a formatting function (should be written by yourself), the first parameter (arg prod spec id) according to the second parameter (120) formatting and return the result to the v bill code, according to the function naming method, the above ** should be the standard format for getting the date.

4 answers2024-02-09

sele date,a.win, b, lose from table, (sele date count(result) as win from table where rsult='Win'group by date )a,,(sele date count(result) as pay from table where rsult='Pay'group by date )b where table. date=table. >>>More

4 answers2024-02-09

select * from log a,(select ,max(date) from logwhere id='10000' >>>More

18 answers2024-02-09

Enterprise Manager directly with SQL has this feature.

12 answers2024-02-09

Lili: Landlord, Lily is out of print, there used to be a capsule toy machine, but now there is none, if you want it, there should be no way. >>>More