what is the equivalent of EXPLAIN form SQLite in SQL Server?

前端 未结 2 1581
半阙折子戏
半阙折子戏 2021-01-12 21:43

I used an SQLite database and run an EXPLAIN statement before executing the actual query to verify if there was any attempt to write on the database.

Now, we have mi

2条回答
  •  灰色年华
    2021-01-12 22:18

    If you do decide to go this route, you could do the following:

    set showplan_xml on
    go
    set noexec on
    go
    select * from sysobjects
    go
    set noexec off
    go
    set showplan_xml off
    go
    

    This will return 3 result sets containing a single column of XML. The 2nd result set is the query plan for the actual query (in this case, select * from sysobjects)

    But as noted in my comment, you'd be better off preventing the user having permissions to make any changes.

    It's also possible to craft statements that are "only" selects but that are also pretty malicious. I could easily write a select that exclusively locks every table in the database and takes an hour to run.

提交回复
热议问题