Saturday, November 14, 2015

Creating a Database (Tutorial)

Creating a Database (Tutorial)
SQL Server 2016

Applies To: SQL Server 2016 Preview
Like many Transact-SQL statements, the CREATE DATABASE statement has a required parameter: the name of the database. CREATE DATABASE also has many optional parameters, such as the disk location where you want to put the database files. When you execute CREATE DATABASE without the optional parameters, SQL Server uses default values for many of these parameters. This tutorial uses very few of the optional syntax parameters.
To create a database
  1. In a Query Editor window, type but do not execute the following code:
2.  CREATE DATABASE TestData
3.  GO
  1. Use the pointer to select the words CREATE DATABASE, and then press F1. The CREATE DATABASE topic in SQL Server Books Online should open. You can use this technique to find the complete syntax for CREATE DATABASE and for the other statements that are used in this tutorial.
  2. In Query Editor, press F5 to execute the statement and create a database named TestData.
When you create a database, SQL Server makes a copy of the model database, and renames the copy to the database name. This operation should only take several seconds, unless you specify a large initial size of the database as an optional parameter.
Note
The keyword GO separates statements when more than one statement is submitted in a single batch. GO is optional when the batch contains only one statement.



Creating a Table (Tutorial)

 
Applies To: SQL Server 2016 Preview
To create a table, you must provide a name for the table, and the names and data types of each column in the table. It is also a good practice to indicate whether null values are allowed in each column.
Most tables have a primary key, made up of one or more columns of the table. A primary key is always unique. The Database Engine will enforce the restriction that any primary key value cannot be repeated in the table.
For a list of data types and links for a description of each, see Data Types (Transact-SQL).
System_CAPS_noteNote
The Database Engine can be installed as case sensitive or non-case sensitive. If the Database Engine is installed as case sensitive, object names must always have the same case. For example, a table named OrderData is a different table from a table named ORDERDATA. If the Database Engine is installed as non-case sensitive, those two table names are considered to be the same table, and that name can only be used one time.

To create a database to contain the new table

  • Enter the following code into a Query Editor window.
    USE master;
    GO
    
    --Delete the TestData database if it exists.
    IF EXISTS(SELECT * from sys.databases WHERE name='TestData')
    BEGIN
        DROP DATABASE TestData;
    END
    
    --Create a new database called TestData.
    CREATE DATABASE TestData;
    Press the F5 key to execute the code and create the database.
    

Switch the Query Editor connection to the TestData database

  • In a Query Editor window, type and execute the following code to change your connection to the TestData database.
    USE TestData
    GO
    

To create a table

  • In a Query Editor window, type and execute the following code to create a simple table named Products. The columns in the table are namedProductIDProductNamePrice, and ProductDescription. The ProductID column is the primary key of the table. intvarchar(25)money, and text are all data types. Only the Price and ProductionDescription columns can have no data when a row is inserted or changed. This statement contains an optional element (dbo.) called a schema. The schema is the database object that owns the table. If you are an administrator, dbo is the default schema. dbo stands for database owner.
    CREATE TABLE dbo.Products
       (ProductID int PRIMARY KEY NOT NULL,
        ProductName varchar(25) NOT NULL,
        Price money NULL,
        ProductDescription text NULL)
    GO

70-462: Administering Microsoft SQL Server 2012 Databases


 70-462

Microsoft SQL Server logo
  • Published:
     June 11, 2012
  • Languages:
     English, Chinese (Simplified), French, German, Japanese, Portuguese (Brazil)
  • Audiences:
    IT professionals
  • Technology:
     Microsoft SQL Server 2012
  • Credit toward certification:
     MCP, MCSA, MCSE

Administering Microsoft SQL Server 2012 Databases

$150.00 USD*
Secondary and higher education students are eligible for special academic pricing. See Exam policies and FAQ for details. Pricing does not reflect any promotional offers or reduced pricing for Microsoft IT Academy program members, Microsoft Certified Trainers, and Microsoft Partner Network program members. Pricing is subject to change without notice. Pricing does not include applicable taxes. Please confirm exact pricing with the exam provider before registering to take an exam.

Skills measured

This exam measures your ability to accomplish the technical tasks listed below. The percentages indicate the relative weight of each major topic area on the exam. The higher the percentage, the more questions you are likely to see on that content area on the exam. View video tutorials about the variety of question types on Microsoft exams.
Please note that the questions may test on, but will not be limited to, the topics described in the bulleted text.
Do you have feedback about the relevance of the skills measured on this exam? Please send Microsoft your comments. All feedback will be reviewed and incorporated as appropriate while still maintaining the validity and reliability of the certification process. Note that Microsoft will not respond directly to your feedback. We appreciate your input in ensuring the quality of the Microsoft Certification program.
If you have concerns about specific questions on this exam, please submit an exam challenge.
Install and configure (19%)
  • Plan installation
    • Evaluate installation requirements; design the installation of SQL Server and its components (drives, service accounts, etc.); plan scale-up vs. scale-out basics; plan for capacity, including if/when to shrink, grow, autogrow, and monitor growth; manage the technologies that influence SQL architecture (for example, service broker, full text, scale out, etc.); design the storage for new databases (drives, filegroups, partitioning); design database infrastructure; configure a SQL Server standby database for reporting purposes; Windows-level security and service level security; Core mode installation; benchmark a server before using it in a production environment (SQLIO, Tests on SQL Instance); choose the right hardware
  • Install SQL Server and related services
    • Test connectivity; enable and disable features; install SQL Server database engine and SSIS (not SSRS and SSAS); configure an OS disk
  • Implement a migration strategy
    • Restore vs detach/attach; migrate security; migrate from a previous version; migrate to new hardware; migrate systems and data from other sources
  • Configure additional SQL Server components
    • Set up and configure all SQL Server components (Engine, AS, RS and SharePoint integration) in a complex and highly secure environment; configure full-text indexing; SSIS security; filestream; filetable
  • Manage SQL Server Agent
    • Create, maintain, and monitor jobs; administer jobs and alerts; automate (setup, maintenance, monitoring) across multiple databases and multiple instances; send to "Manage SQL Server Agent jobs"
Preparation resources
Maintain instances and databases (17%)
Optimize and troubleshoot (14%)
Manage data (19%)
Implement security (18%)
Implement high availability (12%)

Who should take this exam?

This exam is intended for database professionals who perform installation, maintenance, and configuration tasks. Other responsibilities include setting up database systems, making sure those systems operate efficiently, and regularly storing, backing up, and securing data from unauthorized access.

More information about exams

Preparing for an exam
We recommend that you review this exam preparation guide in its entirety and familiarize yourself with the resources on this website before you schedule your exam. See the Microsoft Certification exam overview for information about registration, videos of typical exam question formats, and other preparation resources. For information on exam policies and scoring, see the Microsoft Certification exam policies and FAQs.
Note
This preparation guide is subject to change at any time without prior notice and at the sole discretion of Microsoft. Microsoft exams might include adaptive testing technology and simulation items. Microsoft does not identify the format in which exams are presented. Please use this preparation guide to prepare for the exam, regardless of its format. To help you prepare for this exam, Microsoft recommends that you have hands-on experience with the product and that you use the specified training resources. These training resources do not necessarily cover all of the topics listed in the "Skills measured" section.