[Transact-SQL] DROP SCHEMA TEST CASCADE: keyword 'CASCADE' Incorrect syntax near

SCHEMA SQL server translated as "architecture", in the textbook "model."

Both are completely equivalent, need to be further explored.

T-SQL: Create a database schema


Examples of the SQL server on the test materials:

1. Create mode:

Teaching materials [Example 3.3] - P79

Creation mode, and create a basic table in this mode

CREATE SCHEMA TEST AUTHORIZATION WANG
CREATE TABLE TAB1   
( 
    COL1 SMALLINT, 
    COL2 INT,
    COL3 CHAR(20),
    COL4 NUMERIC(10,3),
    COL5 DECIMAL(5,2)
);

[Note] using the above example, the need for user "WANG" in advance

REF:CREATE SCHEMA (Transact-SQL)

2. Delete mode:

(1) [Example 3.4] to write directly on the textbook - P80:

Delete mode TEST, while the pattern defined in the table TAB1 also deleted

DROP SCHEMA TEST CASCADE

Tip error: 

关键字 'CASCADE' 附近有语法错误。

Visible: SQLserver does not support the use of CASCADE in SCHEMA DROP .

(2) do not write CASCADE, delete TEST:

DROP SCHEMA TEST

SQL server prompt:

无法对 'TEST' 执行 drop schema,因为对象 'TAB1' 正引用它。

(3) workaround: delete the base table in this mode, and then delete mode.

DROP TABLE TEST.TAB1
DROP SCHEMA TEST

REF:DROP SCHEMA (Transact-SQL)

 

Published 15 original articles · won praise 41 · views 4123

Guess you like

Origin blog.csdn.net/qq_38975453/article/details/104691601