Telechargé par youcef hedibel

Tutorial SQLServer 03

publicité
Microsoft SQL Server Management Studio
New Database…
SQL Server
Databases
1
1
pkatts
Management Studio
2
Connect to Server
Connect
3
Login…
New
Security
4
\
DomainName\pkatts
Vista
Windows XP
Search…
ComputerName\pkatts
Server
OK
5
SQL
9
0
z

a
_n, act, %783, Second

act_52_t
n24

c0untries [email protected], govmnt (records), gl0b#
$urvey
SQL
_
a..z
_
Countries Statistics, Global Survey,
Uppercase
_RealSport, FullName, DriversLicenseNumber
Countries Statistics], [Global Survey
FullName], [DriversLicenseNumber
SQL Server Management
New
1
Databases
Database…
2
MotorVehicleAdministration
Microsoft SQL Server
Database Owner
dbo
dbo
default
\
Owner
Select Database Owner
Check Names
Browse…
Objects
dialog
OK
DomainName\pkatts
central\pkatts
default
Browse…
Properties
1
Owner
DomainName
MyComputer
DomainName
Co mputer Name
New
OK
Database
Mb 2
New
Initial Size
Database
Initial Size
Database Files

5
Microsoft SQL Server
Drive:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
OK
New Database
.MDF
New
Path
Database
1
Path
Microsoft SQL
2
Windows Explorer
C:
Server Database Development
3
New Database
Microsoft SQL Server Database Development
4
5
OK
6
model master
4
Microsoft SQL Server
tempdb msdb
Microsoft SQL Server
Microsoft SQL
master
Server
master
SQL
CREATE DATABASE DatabaseName
SQL
SQL
CREATE DATABASE
DatabaseName
SQL
SQL
Microsoft SQL
SQL
";"
Server
CREATE DATABASE DatabaseName;
CREATE DATABASE NationalCensus;
CREATE DATABASE DatabaseName
ON PRIMARY
( NAME = LogicalName, FILENAME = Path )
DatabaseName
Path
LogicalName
.mdf
CREATE DATABASE NationalCensus
ON PRIMARY
( NAME = DataRepository, FILENAME = 'C:\Exercises\NationalCensus.mdf')
GO
Log file
CREATE DATABASE DatabaseName
ON PRIMARY
( NAME = LogicalName, FILENAME = Path.mdf )
LOG ON
( NAME = LogicalName, FILENAME = Path.ldf )
LOG ON
.ldf
CREATE DATABASE NationalCensus
ON PRIMARY
( NAME = DataRepository, FILENAME = 'C:\Exercises\NationalCensus.mdf')
LOG ON
( NAME = DataLog, FILENAME = 'C:\Exercises\NationalCensus.ldf')
GO
SQL
1
New Query
CREATE DATABASE RealEstate1
ON PRIMARY
( NAME = DataRepository, FILENAME = 'C:\Microsoft SQL Server Database
Development\RealEstate1.mdf')
LOG ON
( NAME = DataLog, FILENAME = 'C:\Microsoft SQL Server Database
Development\RealEstate1.ldf')
GO
F5
SQL
SQL
Microsoft SQL Server
Templates
Template Explorer
Template Explorer
Template Explorer
View

Create Database
Databases

Databases
Connect to Database Engine
Open
Create Database
OK
Microsoft SQL Server
-- =============================================
-- Create database template
-- =============================================
USE master
GO
-- Drop the database if it already exists
IF EXISTS (
SELECT name
FROM sys.databases
WHERE name = N'<Database_Name, sysname, Database_Name>'
)
DROP DATABASE <Database_Name, sysname, Database_Name>
GO
CREATE DATABASE <Database_Name, sysname, Database_Name>
GO
CREATE
GO DATABASE
Query
Specify Values For Tmplate Parameters
Microsoft SQL Se rver
Close
OK
Delete
existing connections
1
MotorVehicleAdministration
Delete
OK
SQL
DROP
SQL
DATABASE
DROP DATABASE DatabaseName;
SQL
SQL
1
2
DROP DATABASE RealEstate1;
GO
F5
USE
USE DatabaseName;
USE DatabaseName;
SQL Server Management Studio
SQL Server Management Studio
Refresh
Refresh
Databases
Namespaces
Namespaces
namespaces
namespaces
namespace
namespace
namespace
namespace
namespace
namespace
namespace
Schema_n
Schema2
Schema1
Microsoft SQL Server
sys
sys
view
databases
databases
Object Explorer
Databases
Shemas
Security
New Schema…
Schema Name
Schemas
Schema – New
OK
7
Schema1
Something1
Schema1.Something1
Microsoft SQL Server Management Studio

UtilityCompany1

Téléchargement