SQL Table Delete and Truncate, Schemas and Synonyms
-
Upload
aaron-buma -
Category
Software
-
view
736 -
download
1
Transcript of SQL Table Delete and Truncate, Schemas and Synonyms
Presented by Aaron Buma
Table Data OperationsDELETE TRUNCATE
You can filter on what you DELETE
IDENTITY counters are not reset
Can be rolled back (each row logged)
You can’t filter, it clears whole table
Resets the IDENTITY counter
Cannot be rolled back (only page destruction logged)
Can’t do if: there are triggers, table is in log shipping or if it has FK’s
Schemas Default is “dbo”
Ability to group objects
A layer of permissions between Database and Object levels
Clean Code – Intent through name
Duplicate object names, but in different schemas
Schemas – Can be applied to: Table
View
Stored procedure
Function (all 3 types)
CLR table-valued function
CLR stored procedure
CLS scalar function
CLR aggregate function
Extended SPROC
Synonyms Create a short-hand name to a fully qualified object
Databasename. SchemaName.tableOrders -> orders SELECT * FROM Databasename. SchemaName.tableOrders;
SELECT * FROM orders;
Double-Edged Sword – Abstracts underlying structure
Extra level of complexity
Synonyms – Data Permissions CONTROL
DELETE
EXECUTE
INSERT
SELECT
UPDATE
TAKE OWNERSHIP
VIEW DEFINITION
Synonyms - Limitations
Loosely bound – no warnings of references with delete
Can’t be referenced in a DDL
No Chaining
When being created, the object it is referencing doesn’t have to exist
Demo