This is a discussion on SQL Server 2005 within the Database Support forums, part of the Web Development category; Aggregate - CREATE AGGREGATE - DROP AGGREGATE Application Role - CREATE APPLICATION ROLE - ALTER APPLICATION ROLE - DROP APPLICATION ROLE Assembly - CREATE ASSEMBLY - ALTER ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Aggregate - CREATE AGGREGATE - DROP AGGREGATE Application Role - CREATE APPLICATION ROLE - ALTER APPLICATION ROLE - DROP APPLICATION ROLE Assembly - CREATE ASSEMBLY - ALTER ASSEMBLY - DROP ASSEMBLY ALTER AUTHORIZATION BACKUP BACKUP CERTIFICATE BEGIN [DIALOG [CONVERSATION]] Certificate - ALTER CERTIFICATE - CREATE CERTIFICATE - DROP CERTIFICATE CHECKPOINT COMMIT Contract - CREATE CONTRACT - DROP CONTRACT Credential - CREATE CREDENTIAL - ALTER CREDENTIAL - DROP CREDENTIAL Database - CREATE DATABASE - ALTER DATABASE - DROP DATABASE DBCC CHECKALLOC - Check consistency of disk allocation. DBCC CHECKCATALOG - Check catalog consistency DBCC CHECKCONSTRAINTS - Check integrity of table constraints. DBCC CHECKDB - Check allocation, and integrity of all objects. DBCC CHECKFILEGROUP - Check all tables and indexed views in a filegroup. DBCC CHECKIDENT - Check identity value for a table. DBCC CHECKTABLE - Check integrity of a table or indexed view. DBCC CLEANTABLE - Reclaim space from dropped variable-length columns. DBCC dllname - Unload a DLL from memory. DBCC DROPCLEANBUFFERS - Remove all clean buffers from the buffer pool. DBCC FREE... CACHE - Remove items from cache. DBCC HELP - Help for DBCC commands. DBCC INPUTBUFFER - Display last statement sent from a client to a database instance. DBCC OPENTRAN - Display information about recent transactions. DBCC OUTPUTBUFFER - Display last statement sent from a client to a database instance. DBCC PROCCACHE - Display information about the procedure cache DBCC SHOW_STATISTICS - Display the current distribution statistics DBCC SHRINKDATABASE - Shrink the size of the database data and log files. DBCC SHRINKFILE - Shrink or empty a database data or log file. DBCC SQLPERF - Display transaction-log space statistics. Reset wait and latch statistics. DBCC TRACE... - Enable or Disable trace flags DBCC UPDATEUSAGE - Report and correct page and row count inaccuracies in catalog views DBCC USEROPTIONS - Return the SET options currently active DBCC deprecated commands DECLARE Default - CREATE DEFAULT - DROP DEFAULT DELETE DENY - DENY Object permissions - DENY User/Role permissions Endpoint - CREATE ENDPOINT - ALTER ENDPOINT - DROP ENDPOINT Event - CREATE EVENT NOTIFICATION - DROP EVENT NOTIFICATION EXECUTE EXECUTE AS Fulltext Catalog - CREATE FULLTEXT CATALOG - ALTER FULLTEXT CATALOG - DROP FULLTEXT CATALOG Fulltext Index - CREATE FULLTEXT INDEX - ALTER FULLTEXT INDEX - DROP FULLTEXT INDEX Function - CREATE FUNCTION - ALTER FUNCTION - DROP FUNCTION GO GRANT - GRANT Object permissions - GRANT User/Role permissions Index - CREATE INDEX - ALTER INDEX - DROP INDEX INSERT iSQL -U user -P password -i script.sql -o logfile.log Key - CREATE ASYMMETRIC KEY - ALTER ASYMMETRIC KEY - DROP ASYMMETRIC KEY - CREATE SYMMETRIC KEY - OPEN SYMMETRIC KEY - CLOSE SYMMETRIC KEY - ALTER SYMMETRIC KEY - DROP SYMMETRIC KEY KILL KILL QUERY NOTIFICATION KILL STATS JOB Login - CREATE LOGIN - ALTER LOGIN - DROP LOGIN Master Key - CREATE MASTER KEY - ALTER MASTER KEY - BACKUP MASTER KEY - DROP MASTER KEY - RESTORE MASTER KEY - ALTER SERVICE MASTER KEY - BACKUP SERVICE MASTER KEY - RESTORE SERVICE MASTER KEY Message Type - CREATE MESSAGE TYPE - ALTER MESSAGE TYPE - DROP MESSAGE TYPE Partition Function - CREATE PARTITION FUNCTION - ALTER PARTITION FUNCTION - DROP PARTITION FUNCTION Partition Scheme - CREATE PARTITION SCHEME - ALTER PARTITION SCHEME - DROP PARTITION SCHEME Procedure - CREATE PROCEDURE - ALTER PROCEDURE - DROP PROCEDURE Queue - CREATE QUEUE - ALTER QUEUE - DROP QUEUE Remote Service Binding - CREATE REMOTE SERVICE BINDING - ALTER REMOTE SERVICE BINDING - DROP REMOTE SERVICE BINDING RESTORE - RESTORE DATABASE Complete RESTORE DATABASE Partial RESTORE DATABASE Files RESTORE LOGS RESTORE DATABASE_SNAPSHOT RESTORE FILELISTONLY - List database and log files RESTORE HEADERONLY - List backup header info RESTORE LABELONLY - Media info RESTORE REWINDONLY - Rewind and close tape device RESTORE VERIFYONLY REVERT REVOKE - REVOKE Object permissions - REVOKE User/Role permissions Role - CREATE ROLE - ALTER ROLE - DROP ROLE ROLLBACK Route - CREATE ROUTE - ALTER ROUTE - DROP ROUTE Schema - CREATE SCHEMA - ALTER SCHEMA - DROP SCHEMA SELECT SEND SERVERPROPERTY Service - CREATE SERVICE - ALTER SERVICE - DROP SERVICE SESSION_USER SESSIONPROPERTY SET @local_variable SET SHUTDOWN Signature - ADD SIGNATURE - DROP SIGNATURE Statistics - CREATE STATISTICS - UPDATE STATISTICS - DROP STATISTICS Synonym - CREATE SYNONYM - DROP SYNONYM Table - CREATE TABLE - ALTER TABLE - DROP TABLE - TRUNCATE TABLE Transaction - BEGIN DISTRIBUTED TRANSACTION - BEGIN TRANSACTION - COMMIT TRANSACTION Trigger - CREATE TRIGGER - ALTER TRIGGER - ENABLE TRIGGER - DISABLE TRIGGER - DROP TRIGGER Type - CREATE TYPE - DROP TYPE UNION UPDATE User - CREATE USER - ALTER USER - DROP USER USE View - CREATE VIEW - ALTER VIEW - DROP VIEW XML Schema Collection - CREATE XML SCHEMA COLLECTION - ALTER XML SCHEMA COLLECTION - DROP XML SCHEMA COLLECTION |
| Sponsored Links |
| |||
| First One CREATE AGGREGATE Create a user-defined aggregate function. Binding the function will require CREATE ASSEMBLY. Syntax CREATE AGGREGATE [ schema_name . ] aggregate_function_name (@param_name <input_sqltype> ) RETURNS <return_sqltype> EXTERNAL NAME assembly_name [ .class_name ] <input_sqltype> ::= system_scalar_type | { [ udt_schema_name. ] udt_type_name } <return_sqltype> ::= system_scalar_type | { [ udt_schema_name. ] udt_type_name } Key @param_name A parameter in the user-defined aggregate (@ as the first character) value supplied by the user when the function is executed. system_scalar_type Any SQL Server system scalar data type udt_schema_name Schema to which the CLR user-defined type belongs, default=current user schema udt_type_name CLR user-defined type already created in the current database. assembly_name [ .class_name ] Assembly to bind with the user-defined aggregate function and, optionally, the name of the schema to which the assembly belongs and the assembly class that implements the user-defined aggregate default class_name=same as aggregate_name. Examples CREATE AGGREGATE myFunction(@input varchar(500)) RETURNS varchar(500) EXTERNAL NAME [myAssembly].[us.StringUtils.myFunction]; GO Last edited by kingmaker : 10-11-2007 at 07:02 AM. |
| |||
| DROP AGGREGATE Drop a user-defined aggregate function Syntax DROP AGGREGATE [ schema_name . ] aggregate_name If the aggregate function is still referenced by any views, functions, or stored procedures (created with schema binding) then the attempt to drop will fail. Minimum permissions: ALTER permission on the schema, or CONTROL permission on the aggregate. Example DROP AGGREGATE dbo.myAggregate Last edited by kingmaker : 10-11-2007 at 07:02 AM. |
| |||
| CREATE APPLICATION ROLE Add an application role to the current database. Syntax CREATE APPLICATION ROLE application_role_name WITH PASSWORD = 'password' [ , DEFAULT_SCHEMA = schema_name ] Key: password: The password that users will use to activate the application role. schema_name: The first schema that will be searched by the server when it resolves the names of objects for this role. If undefined, the application role will use DBO as its default schema. schema_name can be a schema that does not exist in the database. Example CREATE APPLICATION ROLE Vincentio WITH PASSWORD = '987Gbv876sPYY5m23' , DEFAULT_SCHEMA = Shrew; GO |
| |||
| ALTER APPLICATION ROLE Change the name, password, or default schema of an application role. Syntax ALTER APPLICATION ROLE application_role_name WITH <set_item> [ ,...n ] <set_item> ::= NAME = new_application_role_name | PASSWORD = 'password' | DEFAULT_SCHEMA = schema_name Key: NAME Unique name of the application role. PASSWORD The password for the application role. Password complexity will be checked. DEFAULT_SCHEMA The first schema to be used to resolve object names. can be a schema that does not exist in the database. Examples ALTER APPLICATION ROLE Vincentio WITH PASSWORD = 'some897long_random64string'; GO ALTER APPLICATION ROLE Vincentio WITH NAME = Petruchio; GO |
| |||
| DROP APPLICATION ROLE Remove an application role from the current database. Syntax DROP APPLICATION ROLE rolename Requires ALTER ANY APPLICATION ROLE permission on the database. Example DROP APPLICATION ROLE Vincentio; GO #Now the king told the boogie men, You have to let that raga drop The oil down the desert way, Has been shakin' to the top# - The Clash (Rock the Casbah) Related commands: CREATE APPLICATION ROLE ALTER APPLICATION ROLE Equivalent Oracle command: ALTER SESSION SET CURRENT SCHEMA |
| |||
| CREATE ASSEMBLY Upload an assembly that was previously compiled as a .dll file from managed code for use inside an instance of SQL Server. An Assemby object is a managed application module, other objects may reference this module - stored procedures, triggers, CLR functions, user-defined aggregates/types. Syntax CREATE ASSEMBLY assembly_name [ AUTHORIZATION owner_name ] FROM { <client_assembly_specifier> | <assembly_bits> [ ,...n ] } [WITH PERMISSION_SET = { SAFE | EXTERNAL_ACCESS | UNSAFE } ] [ ; ] <client_assembly_specifier> :: = '[\\computer_name\]share_name\[path\]manifest_file_name' | '[local_path\]manifest_file_name' <assembly_bits> :: = { varbinary_literal | varbinary_expression } Key: assembly_name The (unique) name of the assembly. owner_name The usernname or role as owner of the assembly. client_assembly_specifier The local path or network location for the assembly being uploaded. A fixed string or an expression evaluating to a fixed string. (Assembly manifest filename) assembly_bits List of binary values that make up the assembly and it's dependent assemblies, starting with the root-level assembly. PERMISSION_SET SAFE Restrictive code access permissions, no access to external files/networks. PERMISSION_SET EXTERNAL_ACCESS Allow some external system resources, files/networks/Registry PERMISSION_SET UNSAFE unrestricted access to resources Permissions: CREATE ASSEMBLY EXTERNAL ACCESS ASSEMBLY for PERMISSION_SET = EXTERNAL_ACCESS SYSADMIN fixed server role for PERMISSION_SET = UNSAFE owner_name must either be the name of a role of which the current user is a member, or the current user must have IMPERSONATE permission on owner_name. If not specified, ownership is given to the current user. When accessing client_assembly_specifier, SQL Server will impersonate either the security context of the current Windows login or the security context of the SQL Server service account. Example CREATE ASSEMBLY MyDemo FROM 'C:\democode\HelloWorld.dll' WITH PERMISSION_SET = SAFE; |
| |||
| ALTER ASSEMBLY Alter the SQL Server catalog properties of an assembly, add or remove files associated with the assembly. Syntax ALTER ASSEMBLY assembly [FROM client_assembly_specifier | assembly_bits ] [WITH assembly_option [ ,...n ] ] [DROP FILE { file_name [ ,...n ] | ALL } ] [ADD FILE FROM { client_file_specifier [ AS file_name ] | file_bits AS file_name } [,...n ] ] [ ; ] Key: assembly The assembly you want to modify. (Must already exist) client_assembly_specifier The network or local location where the assembly being refreshed is located: '\\computer\share\[path\]manifest_file_name' '[local_path\]manifest_file_name' assembly_bits The binary value for the assembly: {varbinary_literal | varbinary_expression} assembly_option PERMISSION_SET = { SAFE | EXTERNAL_ACCESS | UNSAFE } | VISIBILITY = { ON | OFF } | UNCHECKED DATA Permissions: Visibility is required when creating CLR functions, stored procedures, triggers, user-defined types, and user-defined aggregate functions. (but not for calling by other assemblies.) The UNCHECKED DATA option will postpone consistency checks of table rows until a later time, if any CHECK constraints are present, they are disabled and marked untrusted. Use this feature with great caution. DROP FILE will remove one or more files associated with the assembly. DROP FILE.. ADD FILE.. will execute the drop first, this lets you replace a file with the same name. Examples ALTER ASSEMBLY MyClass1 ADD FILE FROM 'C:\MyProject\ClassASM1.cs'; ALTER ASSEMBLY MyClass2 FROM 'C:\MyProject\Samples\ClassASM2.dll' |
| |||
| DROP ASSEMBLY Remove an assembly and all its associated files from the current database. Syntax DROP ASSEMBLY assembly [,...n ] [WITH NO DEPENDENTS ] [ ; ] Key WITH NO DEPENDENTS Drop only assembly_name and none of the dependent/referenced assemblies. default is to drop all dependent assemblies. DROP ASSEMBLY returns an error if the assembly is referenced by another assembly in the database or if it is used by a CLR function, procedure, trigger, user-defined type or aggregate in the current database. DROP ASSEMBLY does not interfere with any code referencing the assembly that is currently running. After DROP ASSEMBLY executes, any new attempts to invoke the assembly code will fail. Example DROP ASSEMBLY MyCode |
| |||
| ALTER AUTHORIZATION Change the ownership of an entity. Syntax ALTER AUTHORIZATION ON [entity_type::] entity TO SCHEMA OWNER ALTER AUTHORIZATION ON [entity_type::] entity TO principal Key principal The name of the principal that will own the entity entity_type The class of the entity, one of: Database Schema XML Schema Collection Assembly Role Object (table,view,function,procedure,queue,synonym) Fulltext Catalog Certificate Type Message Type Contract Service Remote Service Binding Route Symmetric Key Endpoint You cannot change the owner of a system database (master, model, tempdb), the resource database, or any database that is used as a distribution database. The ownership of entity types not listed above cannot be transferred. Example ALTER AUTHORIZATION ON OBJECT::tblParts TO BillG; ALTER AUTHORIZATION ON tblCustomers TO MichikoOsada; GO |
| |||
| BACKUP Backup an entire database, transaction log, file(s) or filegroup(s). Syntax --Backup an entire database BACKUP DATABASE {database | @database_name_var } TO backup_device [ ,...n ] [[MIRROR TO backup_device [ ,...n ] ] [ ...next-mirror ] ] [WITH options ] --Backup specific files or filegroups BACKUP DATABASE {database_name | @database_name_var } file_or_filegroup [ ,...f ] TO backup_device [ ,...n ] [[MIRROR TO backup_device [ ,...n ] ] [ ...next-mirror ] ] [WITH options ] --Backup a transaction log BACKUP LOG {database_name | @database_name_var } { TO backup_device [ ,...n ] [[MIRROR TO backup_device [ ,...n ] ] [ ...next-mirror ] ] [WITH options ] } --Truncate the transaction log BACKUP LOG {database | @database_name_var} WITH {NO_LOG | TRUNCATE_ONLY} Options: BLOCKSIZE = {blocksize | @blocksize_variable} {CHECKSUM | NO_CHECKSUM } {STOP_ON_ERROR | CONTINUE_AFTER_ERROR} DESCRIPTION = {'text' | @text_variable} DIFFERENTIAL EXPIREDATE = {date | @date_var} | RETAINDAYS = {days | @days_var} PASSWORD = {password | @password_variable} {FORMAT | NOFORMAT } {INIT | NOINIT} {NOSKIP | SKIP} MEDIADESCRIPTION = {'text' | @text_variable} MEDIANAME = {media_name | @media_name_variable} MEDIAPASSWORD = {mediapassword | @mediapassword_variable} NO_TRUNCATE ** {NORECOVERY | STANDBY = undo_file_name } ** NAME = {backup_set_name | @backup_set_name_var} {NOREWIND | REWIND} {NOUNLOAD | UNLOAD} RESTART STATS [= percentage] COPY_ONLY ** = option for BACKUP LOG command only Multiple options can be specified with or without commas to separate e.g. option option or option, option file_or_filegroup :: = { FILE = logical_file_name FILE = @logical_file_name_var FILEGROUP = logical_filegroup_name FILEGROUP = @logical_filegroup_name_var READ_WRITE_FILEGROUPS } backup_device ::= { logical_backup_device_name @logical_backup_device_name_var {DISK | TAPE} = {'physical_backup_device_name' | @physical_backup_device_name_var} } The option NO_LOG /TRUNCATE_ONLY will be removed in a future version of SQL Server. Examples (These assume the backup devices already exist) -- Backup the 'MySample' database to the logical backup device 'MySampleDevice' -- Simple recovery model BACKUP DATABASE MySample TO MySampleDevice -- Back up the full 'MySample2' database to the logical backup device 'MySample2Device'. -- Full recovery model BACKUP DATABASE MySample2 TO MySample2Device -- Then Backup the MySample2 log file. BACKUP LOG MySample2 TO MySample2Device |
| |||
| BACKUP CERTIFICATE Export a certificate to a file. Syntax: BACKUP CERTIFICATE certname TO FILE = 'pathname' [ WITH PRIVATE KEY ( FILE = 'path_to_private_key_file' , ENCRYPTION BY PASSWORD = 'encryption_password' [ , DECRYPTION BY PASSWORD = 'decryption_password' ] ) ] If the private key is encrypted with a password in the database, then that decryption password must be specified. When you back up the private key to a file, encryption is required. Example BACKUP CERTIFICATE MyCert TO FILE = 'c:\certs\MyCert' WITH PRIVATE KEY ( FILE = 'c:\keys\Mykey' , ENCRYPTION BY PASSWORD = 'thisisa1ongpassw0rd' ); GO |
| |||
| ALTER CERTIFICATE Alter a certificate in the database. Syntax: ALTER CERTIFICATE certificate REMOVE PRIVATE KEY ALTER CERTIFICATE certificate WITH PRIVATE KEY ( private_key_spec [ ,... ] ) ALTER CERTIFICATE certificate WITH ACTIVE FOR BEGIN DIALOG = [ON | OFF] private_key_spec: FILE = 'path_to_private_key' DECRYPTION BY PASSWORD = 'key_password' ENCRYPTION BY PASSWORD = 'password' Key: key_password Password to decrypt the private key. password Password to encrypt the private key of the certificate in the database. REMOVE PRIVATE KEY The key should no longer be maintained inside the database. ACTIVE FOR BEGIN_DIALOG Make the cert available to the initiator of a Service Broker dialog conversation If password complexity is enforced, the password must be > 8 chars and contain upper/lower case and numeric/ Non-alphanumeric characters. The private key must correspond to the public key specified by certificate Requires ALTER permission on the certificate. Examples ALTER CERTIFICATE MyCert1 WITH PRIVATE KEY (DECRYPTION BY PASSWORD = 'oldCertPassword3456gsf', ENCRYPTION BY PASSWORD = 'newCertPassword$214kH'); GO ALTER CERTIFICATE MyCert2 WITH PRIVATE KEY (ENCRYPTION BY PASSWORD = 'newKeyPassword64Jjh7', DECRYPTION BY PASSWORD = 'oldKeyPassword706tt'); GO |
| |||
| CREATE CERTIFICATE Add a certificate to the database. Syntax: CREATE CERTIFICATE certificate [ AUTHORIZATION user_name ] {FROM existing_keys | generate_new_keys } [ACTIVE FOR BEGIN_DIALOG = {ON | OFF }] existing_keys: ASSEMBLY assembly_name {[EXECUTABLE ] FILE = 'path_to_file' [WITH PRIVATE KEY ( private_key_options )]} generate_new_keys: [ENCRYPTION BY PASSWORD = 'password'] WITH SUBJECT = 'certificate_subject_name' [ , date_options [ ,...n ] ] private_key_options: FILE = 'path_to_private_key' [, DECRYPTION BY PASSWORD = 'password' ] [, ENCRYPTION BY PASSWORD = 'password' ] date_options: START_DATE = 'mm/dd/yyyy' EXPIRY_DATE = 'mm/dd/yyyy' Key: user_name The user that will own the certificate. assembly_name A signed assembly already loaded into the database. path_to_file The path (local or UNC) , including filename to a DER-encoded file that contains the certificate. WITH PRIVATE KEY Load the private key of the certificate into SQL Server. START_DATE Date the certificate becomes valid (default=current date.) EXPIRY_DATE Date the certificate expires (default= 1 year after START_DATE) ACTIVE FOR BEGIN_DIALOG Make available to the initiator of a Service Broker dialog conversation. Users of these built-in functions for encryption and signing must decide when to check if the certificate has expired. Example USE MyDb; CREATE CERTIFICATE SS64 ENCRYPTION BY PASSWORD = 'pG6464qwerty247y' WITH SUBJECT = 'Demonstration certificate', EXPIRY_DATE = '02/28/2014'; GO |
| |||
| DROP CERTIFICATE Remove a certificate from the database. Syntax: DROP CERTIFICATE certificate_name certificate_name Name of the certificate Certificates can only be dropped if no entities are associated with them. Requires CONTROL permission on the certificate. Examples USE MyDatabase; DROP CERTIFICATE MyCert01; |
| |||
| CHECKPOINT Write all dirty pages to disk. Syntax CHECKPOINT [duration] Key duration Time for the checkpoint to complete (seconds). CHECKPOINT will write to disk all those data pages in the buffer cache of the current database which have been modified, but not yet written to disk. Issuing SHUTDOWN WITH NOWAIT or directly stopping the msSqlServer service from the Windows control panel will not perform a checkpoint. When the database is restarted, this will force a rollback operation to occur for any uncompleted transactions. Example CHECKPOINT |
| |||
| COMMIT Mark the end of a transaction. Syntax COMMIT COMMIT WORK COMMIT TRAN[SACTION] [transaction_name | @transaction_var] [;] A commit will make any data modifications performed since the start of the transaction a permanent part of the database. transaction_name is simply used by programmers to associate a BEGIN TRANSACTION statement with a COMMIT TRANSACTION statement. It is ignored by the database engine. The syntax COMMIT or COMMIT WORK is compatible with SQL-92 Example COMMIT |
| |||
| CREATE CONTRACT Create a contract in the database. Syntax: CREATE CONTRACT contract [AUTHORIZATION owner ] ( {{message_type_name | [DEFAULT ] } SENT BY { INITIATOR | TARGET | ANY } } [ ,...n] ) [;] Key: contract Name of the contract owner Owner of the contract(database user or role) message_type_name Name of a message type to be included as part of the contract. A contract must allow the initiator to send a message, the statement will fail if the contract does not contain at least one message type that is SENT BY ANY or SENT BY INITIATOR. Example CREATE CONTRACT [//ss64.com/Sales/ContractSale] ( [//ss64.com/Sales/SubmitOrder] SENT BY INITIATOR, [//ss64.com/Sales/ApproveOrder] SENT BY TARGET ) ; |