[會陸續更新]
與使用者/帳號有關的 :
l Create Login
CREATE LOGIN testLogin WITH password='!QAZ2wsx'
l Create User
CREATEUSER testUser FROM LOGIN testLogin
l Alert Login (ex: 用來修改登入密碼)
ALTER LOGIN testLogin WITH password='@WSX3edc'
l Permissions (ex: 將使用者加到datareader群組)
EXEC sp_addrolemember 'db_datareader', 'testUser'
資料庫相關
l 複製Database
CREATE DATABASE AdventureWorks2 AS COPY OFAdventureWorks
l Index Fragmentation
SELECTo.name AS ObjectName, i.name AS IndexName, ddips.avg_fragmentation_in_percent, ddips.page_count, ddips.compressed_page_count, ddips.index_depth, ddips.record_count FROMsys.dm_db_index_physical_stats(DB_ID('MovieManagement'),
OBJECT_ID('dbo.MovieStage'), DEFAULT, DEFAULT, 'DETAILED') AS ddips JOIN sys.objects AS o ON ddips.object_id = o.object_id JOIN sys.indexes AS i ON ddips.index_id = i.index_id AND ddips.object_id = i.object_id; |
l Rebuild Index
ALTER INDEX AgentPK ONdbo.Agent REBUILD;
留言列表