Things to be consider while creating a Data base
1> Uncheck the Auto Growth of Data files and Transaction File and give the Specific size
2> Place the Data and Log file in different file group
3> Set the Recovery model to Simple/Bulk/Full based on the Importance of the database
4> Check the auto shrink
Example Scripts to Group/Increase the size of the Log/Data file and to clear the Log/data file, Use Northwind database
--
-- TO SRINK THE DATA or LOG FILE
--
USE Northwind;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE Northwind
SET RECOVERY Simple;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (Northwind_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE Northwind
SET RECOVERY FULL;
GO
---------------------------------------------------------------------------------------------
--
-- TO INSERT MORE RECORD TO DATA BASE
--
declare @iCount int
set @iCount=0
MyLoop1:
insert into employees (
LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,
City,Region,PostalCode,Country,HomePhone,Extension,Photo,Notes,ReportsTo,PhotoPath)
values('Test','Test','Test','Test','1948-12-08 00:00:00.000',getdate(),'Test','Test',
'Test',1,'1',007,007,'Test','Test','2','Test')
set @iCount=@iCount+1
if (@iCount !=30000)-- Insert 30000 Records
begin
goto MyLoop1 -- Loop to Insert the Records
end
---------------------------------------------------------------------------------------------
-- SELECT THE RECORD
select EmployeeID, LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,
City,Region,PostalCode,Country,HomePhone,Extension,Photo,Notes,ReportsTo,PhotoPath from employees
-- DELETE THE RECORD TO INCRESE THE SIZE OF THE LOG FILE
delete from employees where lastname='Test'
---------------------------------------------------------------------------------------------
-- SELECT STORED PROCEDURE
Create Procedure Sample_Emp_Sel_Employees
as
select EmployeeID, LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate
from employees
Go
-- EXECUTE SP
exec Sample_Emp_Sel_Employees
No comments:
Post a Comment