පාඨමාලා මාතෘකා Microsoft SQL Server Databases සැකසීම 01 | Tables සහ Views 06 | Queries Optimize සහ Troubleshoot කිරීම 02 | Indexes තේරුම් ගැනීම 03 |Stored Procedures සහ Functions භාවිතය 04 | Transactions කළමනාකරණය 05 | In-Memory Objects
SQL Server Books Online නිෂ්පාදන ලේඛන ගත කිරීම හා මග පෙන්වීම. TechNet හා MSDN හි ප්රකාශිතයි. ස්ථානීය අනුවාද ද ලබා ගත හැක.
MVA සමඟ එක් වන්න! Microsoft Virtual Academy IT Pros සහ Developers ලා වෙනුවෙන් සැකසුණු පාඩම් මාලා රැසක් මිලියනයකට අධික ලියාපදිංචි පරිශීලකයන් යාවත්කාලීන දැනුම් සාගරය
Prabhath Mannapperuma @dprabhathm 01 | Tables සහ Views Prabhath Mannapperuma @dprabhathm
මොඩියුල විශ්ලේෂණය Tables, Schemas සහ Views Temporary Tables සහ Table Variables Common Table Expressions Table Partitioning
Tables නිර්මාණය spaces, keywords සහ symbols අඩංගු නම් යොදා ගන්න එපා. සෑම තීරුවකම දත්ත වර්ග සැලසුම් කරන්න. Null අගයන්ට ඉඩ දෙනවා ද යන්න සැලසුම් කරන්න. primary key සහ foreign key constraints සැලසුම් කරන්න. indexes සැලසුම් කරන්න.
Tables නිර්මාණය
Schemas සමඟ වැඩ කිරීම Naming boundary Security boundary Logically group database objects Security boundary [Server.][Database.]Schema.Object GRANT EXECUTE ON SCHEMA::Sales
Default Schema සහ Name Resolution SELECT * FROM Product User 1 (Default Schema: Sales) User 3 (No Default Schema) Sales.Product dbo.Product User 2 (Default Schema: Ops) Sales Ops dbo
Schemas සමඟ වැඩ කිරීම.
Views යනු? CREATE VIEW HumanResources.EmployeeList (EmployeeID, FamilyName, GivenName) AS SELECT EmployeeID, LastName, FirstName FROM HumanResources.Employee;
Views හඳුන්වා දීම.
Temporary Tables CREATE TABLE #tmpProducts (ProductID INTEGER, ProductName varchar(50));
Table Variables DECLARE @tmpProducts table (ProductID INTEGER, ProductName varchar(50));
Table Variables සහ Temporary Tables
Common Table Expressions WITH CTE_year AS ( SELECT YEAR(orderdate) AS orderyear, custid FROM Sales.Orders ) SELECT orderyear, COUNT(DISTINCT custid) AS cust_count FROM CTE_year GROUP BY orderyear;
Common Table Expressions
Partitioned Tables Sales.Order Filegroup 2000 Filegroup 2001 Date Order Total 20000101 123 999.99 20000105 125 287.99 Date Order Total 20010101 258 199.99 20010105 259 257.99 Date Order Total 20020101 368 199.99 20020105 369 257.99 Date Order Total 20030101 547 129.99 Filegroup 2000 Filegroup 2001 Filegroup 2002 Filegroup 2003
Creating a Partitioned Table CREATE PARTITION FUNCTION PFYears (datetime) AS RANGE RIGHT FOR VALUES (20000101, 20010101, 20020101); --creates 4 partitions: -- <-2000, 2000-2001, 2001-2002, 2002-> CREATE PARTITION SCHEME PSYears AS PARTITION PFYears TO (FG0000, FG2000, FG2001, FG2002, FG2003); -- FG2003 is marked as ‘next used’ CREATE TABLE Sales.Order (OrderDate datetime, OrderNo int, Customer varchar(50), OrderAmount money) ON PSYears(OrderYear);
Partitioned Tables කළමනාකරණය Split Partitions Merge Partitions Switch Partitions -- Create a new partition for 2003 orders -- (created on next used filegroup) ALTER PARTITION FUNCTION PFYears() SPLIT RANGE (20030101); -- Merge 2000 and pre-2000 orders ALTER PARTITION FUNCTION PFYears() MERGE RANGE (20000101); -- Switch partition containing old orders -- to a staging table for archiving ALTER TABLE Sales.Order SWITCH PARTITION $PARTITION.PFYears(20000101) TO archive_staging_table;
Table Partitioning
Tables සහ Views සම්පිණ්ඩනය Tables Schemas Views Temporary Tables Table Variables Common Table Expressions Partitioned Tables