400 likes | 609 Views
SQL DDL. Data Definition Language in SQL. Data types. BLOB: binary large object. CREATE database script file. -- This will create the database 's1234567'for a user with ID = 'SDSMT1234567' CREATE DATABASE s1234567 ON PRIMARY (NAME = s1234567,
E N D
SQL DDL • Data Definition Language in SQL
Data types BLOB: binary large object
CREATE database script file • -- This will create the database 's1234567'for a user with ID = 'SDSMT\1234567' • CREATE DATABASE s1234567 • ON PRIMARY • (NAME = s1234567, • FILENAME = 'C:\program files\microsoft sql server\mssql\data\s1234567.mdf', • SIZE = 2, MAXSIZE = 10, FILEGROWTH = 2) • GO • -- This will create the SQL Logins for a student • EXEC sp_grantlogin 'SDSMT\1234567' • GO • -- This will grant the Login access to the database 's1234567' and make the student a member • -- of the 'public' database role • USE s1234567 • GO • EXEC sp_grantdbaccess 'SDSMT\1234567' • GO • -- This will make the student a member of the 'db_owner' role on the DB, so he/she can do • -- whatever he/she need to in the database • USE s1234567 • GO • EXEC sp_addrolemember 'db_owner', 'SDSMT\1234567' • GO • -- This will change the default database for the student, so when he/she open Query • -- Analyzer, he/she will be attached to the database s1234567 • EXEC sp_defaultdb 'SDSMT\1234567', 's1234567' • GO