You are on page 1of 16

Welcome to SQL Server Training

( Advanced Training - 30 Hours)

Karthikeyan | Technical Consultant


karthik_bss@yahoo.com | +91 9790768919
SQL Server Advanced Training
Session Duration : 1 Hour
Agenda
• Day 3 - Manage Database • Day 3 - Manage Database

• What is Syntax? • Drop Database

• What is Database? • Show all Objects

• Create Database • Show all Tables

• Alter Database • Show all Views

• Show Database • Show all field Names with Data Types in selected Table

• Select Database
Day 3 - Manage Database
What is Syntax?
SQL is followed by unique set of rules and guidelines called Syntax. This tutorial gives you a
quick start with SQL by listing all the basic SQL Syntax:

All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE,
ALTER, DROP, CREATE, USE, SHOW

There is no case sensitive.


What is Database?
The data in RDBMS is stored in database objects called tables. The table is a collection of
related data entries and it consists of columns and rows.
Create Database
The SQL Create Database statement is used to create new SQL database.
Always database name should be unique within the RDBMS.
Make sure you have admin privilege before creating any database. Once a database is created,
you can check it in the list of databases.

Syntax:
CREATE DATABASE <DATABASE NAME>

Example:
CREATE DATABASE CMPortal
Alter Database
Modify existing database name from old name to new name.

Syntax:
ALTER DATABASE <OLD DATABASE NAME> MODIFY NAME = <NEW DATABASE NAME>

Example:
ALTER DATABASE CMPortal MODIFY NAME = SCCMPortal
Show Database
When you have multiple databases in your SQL schema, then before starting your operation,
you would need to select a database where all the operations would be performed.
Always database name should be unique within the RDBMS.

Syntax:
SELECT * FROM SYSDATABASES

Example:
SELECT * FROM SYSDATABASES
Select Database
When you have multiple databases in your SQL Schema, then before starting your operation,
you would need to select a database where all the operations would be performed.
The SQL USE statement is used to select any existing database in SQL schema.
Always database name should be unique within the RDBMS.

Syntax:
USE <DATABASE NAME>

Example:
USE SCCMPortal
Drop Database
• The SQL Drop Database statement is used to drop an existing database in SQL schema.
• Always database name should be unique within the RDBMS.
• Make sure you have admin privilege before dropping any database. Once a database is
dropped.

Note:
Be careful before using this operation because by deleting an existing database would result
in loss of complete information stored in the database.

Syntax:
DROP DATABASE <DATABASE NAME>

Example:
DROP DATABASE SCCMPortal
Show all Objects in selected Database
• Show list of objects in selected Database.

Note:
• U  User Tables
• SQ  Sequences
• V  Views
• P  Procedure

Syntax:
SELECT * FROM SYSOBJECTS

Example:
SELECT * FROM SYSOBJECTS
Show all Tables in selected Database
• Show all tables in selected Database.

Syntax:
SELECT * FROM SYS.TABLES

Example:
SELECT * FROM SYS.TABLES
Show all Views in selected Database
• Show all views in selected Database.

Syntax:
SELECT * FROM SYS.VIEWS

Example:
SELECT * FROM SYS.VIEWS
Show all field names with Data types
• Show all filed names with data types in selected table.

Syntax:
SP_COLUMNS <TABLE NAME>

Example:
SP_COLUMNS STUDENT
LAB Demo
To Learn SQL Server you have use it more
Here are Some reference Links :

To Learn More : Use Microsoft Virtual Academy

Thank You For Practice : Use Microsoft Virtual Labs


For Forum: Use TechNet

Karthikeyan | Technical Consultant


karthik_bss@yahoo.com | +91 9790768919

You might also like