SQL FAQS | |
A constraint is a restriction. Placed at either column or table level, a constraint ensures that your data meets certain data integrity rules. | |
Primary keys are the unique identifiers for each row. They must contain unique values(and hence cannot be NULL). A table can have a maximum of one primary key. | |
We can create primary key using CREATE TABLE command or with an ALTER TABLE command Creating the primary key at table creation CREATE TABLE Customers { CustomerNo int IDENTITY NOTNULL PRIMARY KEY, CustomerName varchar(50) NOT NULL } Creating a primary key on an existing table ALTER TABLE Employees ADD CONSTRAINT PK_EmployeeID PRIMARY KEY (EmployeeID) | |
A table may have more than one combination of columns that could uniquely identify therows in a table; each combination is a candidate key | |
Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrievethe data quicker There are clustered and nonclustered indexes. A clustered index is a special type of indexthat reorders the way records in the table are physically stored. Therefore table can haveonly one clustered index. The leaf nodes of a clustered index contain the data pages. A nonclustered index is a special type of index in which the logical order of the indexdoes not match the physical stored order of the rows on disk. The leaf node of anonclustered index does not consist of the data pages. Instead, the leaf nodes containindex rows. | |
Following are tips which will increase your SQl performance :- | |
7. What is DTS? | |
DTS is used to pull data from various sources into the star schema. | |
The 'fill factor' option specifies how full SQL Server will make each index page. Whenthere is no free space to insert new row on the index page, SQL Server will create newindex page and transfer some rows from the previous page to the new one. This operationis called page splits. You can reduce the number of page splits by setting the appropriatefill factor option to reserve free space on each index page. The fill factor is a value from1 through 100 that specifies the percentage of the index page to be left empty. Thedefault value for fill factor is 0. It is treated similarly to a fill factor value of 100, thedifference in that SQL Server leaves some space within the upper level of the index treefor FILLFACTOR = 0. The fill factor percentage is used only at the time the index iscreated. If the table contains read-only data (or data that very rarely changed), you canset the 'fill factor' option to 100. When the table's data modified very often, you candecrease the fill factor to 70% or whatever you think is best. | |
Redundant Array of Independent Disks (RAID) is a term used to describe the techniqueof improving data availability through the use of arrays of disks and various data-stripingmethodologies. Disk arrays are groups of disk drives that work together to achieve higherdata-transfer and I/O rates than those provided by single large drives. An array is a set ofmultiple disk drives plus a specialized controller (an array controller) that keeps track ofhow data is distributed across the drives. Data for a particular file is written in segmentsto the different drives in the array rather than being written to a single drive. For speed and reliability, it's better to have more disks. When these disks are arranged incertain patterns and use a specific controller, they are called a Redundant Array ofInexpensive Disks (RAID) set. There are several numbers associated with RAID, but themost common are 1, 5 and 10. RAID 1 works by duplicating the same writes on two hard drives. Let's assume you havetwo 20 Gigabyte drives. In RAID 1, data is written at the same time to both drives.RAID1 is optimized for fast writes. RAID 5 works by writing parts of data across all drives in the set (it requires at least threedrives). If a drive failed, the entire set would be worthless. To combat this problem, oneof the drives stores a "parity" bit. Think of a math problem, such as 3 + 7 = 10. You canthink of the drives as storing one of the numbers, and the 10 is the parity part. By removingany one of the numbers, you can get it back by referring to the other two, like this: 3 + X= 10. Of course, losing more than one could be evil. RAID 5 is optimized for reads. RAID 10 is a bit of a combination of both types. It doesn't store a parity bit, so it's fast,but it duplicates the data on two drives to be safe. You need at least four drives for RAID10. This type of RAID is probably the best compromise for a database server. | |
Following are difference between them :- | |
SQL FAQS |
SQL Server FAQ's
Posted by
Ramu
Labels:
SQL Server FAQ's