CLICK HERE TO NAVIGATE TO THE MAIN SITE ...
Go to above site and download the Ringtone cutter full version with out any installation ,you can download freely with out any sign up and no additional installation
|
|
||||
CREATE
DATABASE
|
CREATE
DATABASE database_name
|
||||
CREATE TABLE
|
CREATE TABLE table_name(column_name1
data_type,column_name2 data_type,Column_name3 data_type,....)
|
||||
Select statement
|
SELECT * FROM table_name,
SELECT column_name(s)
FROM table_ name
|
||||
Distinct values
|
SELECT DISTINCT column name(s) FROM table name
|
||||
Where clause
|
SELECT column_name(s) FROM table_nameWHERE column name
operator value
|
||||
AND & OR operator
|
SELECT * FROM Persons
WHERE FirstName='Tove' ANDLastName='Svendson' |
SELECT * FROM Persons
WHEREFirstName='Tove' OR FirstName='Ola' |
SELECT * FROM Persons WHERELastName='Svendson'
AND (FirstName='Tove' OR FirstName='Ola') |
||
ORDER BY
|
SELECT column_name(s) FROM table_name ORDER BY
column_name(s) ASC|DESC
|
||||
INSERT INTO
|
INSERT INTO table_name VALUES (value1, value2, value3,...)
|
||||
UPDATE
|
UPDATE table_name SET column1=value WHERE
some_column=some_value
|
||||
DELETE //(Rows only deleted)
|
DELETE * FROM table_name,
DELETE FROM table_name WHERE some_column=some_value
|
||||
TOP CLAUSE
|
SELECT TOP number | percent column_name(s) FROM table_name
// (top rows returned)
|
||||
LIKE
|
SELECT column_name(s) FROM table_name WHERE column_name
LIKE pattern (// %,_[CHAR LIST], [^CHARLIST],OR [!CHAR LIST])
|
||||
IN (to specify multiple Val’s)
|
SELECT column_name(s) FROM table_name WHERE column_name IN
(value1,value2,...)
|
||||
BETWEEN(Range b/w two Val’s)
|
SELECT column_name(s)
FROM table_name WHERE column_name BETWEEN value1 AND
value2
|
||||
Alias for tables
|
SELECT column_name(s) FROM table_name AS alias_name
|
||||
Alias for columns
|
SELECT column_name
AS alias_name FROM table_name
Ex: SELECT
po.OrderID, p.LastName, p.FirstName
FROM Persons AS p,
Product_Orders AS po
WHERE p.LastName='Hansen' AND p.FirstName='Ola'
-----------------------------------------------------------------------------------------------------
Ex: with out
aliases above ex: SELECT
Product_Orders.OrderID, Persons.LastName, Persons.FirstName FROM
Persons,Product_OrdersWHERE Persons.LastName='Hansen' AND
Persons.FirstName='Ola'
|
||||
JOINS
1.INNER JOIN
|
SELECT column_name(s)
FROM table_name1 INNER JOIN table_name 2
ON table_name1.column_name
=table_name2.column_name
|
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName |
|||
2.LEFT (OR) LEFT OUTER JOIN
|
SELECT column_name(s)FROM table_name1
LEFT JOIN table_name2 ONtable_name1.column_name
=table_name2.column_name
|
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
LEFT JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName |
|||
3.RIGHT (OR) RIGHT OUTER JOIN
|
SELECT column_name(s)
FROM table_name1 RIGHT JOIN table_name2 ON table_name1.column_name=
table_name2.column_name
|
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
RIGHT JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName |
|||
4.FULL JOIN
|
SELECT column_name(s) FROM table_name1
FULL JOIN table_name2 ON table_name1.column_name=table_name2.column_name |
||||
FULL JOIN Ex:
|
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons FULL JOIN Orders ON Persons.P_Id=Orders.P_Id ORDER BY Persons.LastName |
||||
UNION & UNION ALL
|
SELECT column_name(s) FROtable_name1
UNION / UNION ALL
SELECT column_name(s) FROM table_name2 |
(union--returns only distinct values)
(union all--returns duplicate values also) |
|||
SELECT INTO
|
SELECT * / column name INTO new_table_name [IN
externaldatabase]FROM old_tablename
//(to create back up of table or columns)
|
||||
CONSTRAINTS
1.NOT NULL
|
CREATE TABLE Persons (P_Id int NOT NULL UNIQUE, LastName
varchar(255) NOT NULL, FirstName varchar(255),Address varchar(255),City
varchar(255))
|
||||
2.UNIQUE
3. DROP UNIQUE CONSTRAINT
|
1.CREATE TABLE Persons (P_Id int NOT NULL UNIQUE, LastName
varchar(255) NOT NULL, FirstName varchar(255),Address varchar(255),City
varchar(255))
2.For already existing table ALTER TABLE Persons ADD UNIQUE (P_Id)
3.for multiple cols’
ALTER TABLE PersonsADD CONSTRAINT uc_PersonID UNIQUE
(P_Id,LastName)
ALTER TABLE Persons
DROP CONSTRAINT uc_PersonID |
||||
4.PRIMARY KEY
|
CREATE TABLE Persons (P_Id int NOT NULL, LastName
varchar(255) NOT NULL,
FirstName varchar(255),Address varchar(255),City varchar(255), CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName))
For Existed table: ALTER
TABLE Persons ADD PRIMARY KEY (P_Id)
For multiple PK’s: ALTER TABLE Persons ADD CONSTRAINT
pk_PersonID PRIMARY KEY (P_Id,LastName)
To drop PK: ALTER TABLE Persons DROP CONSTRAINT
pk_PersonID
|
||||
5.FOREIGN KEY
|
CREATE TABLE Orders (O_Id int NOT NULL PRIMARY KEY,OrderNo
int NOT NULL,P_Id int FOREIGN KEY REFERENCES Persons(P_Id))
For Existed table:
ALTER TABLE Orders ADD FOREIGN KEY (P_Id)REFERENCES
Persons(P_Id)
To drop FK
:ALTER TABLE Orders DROP CONSTRAINT fk_PerOrders
|
||||
6.CHECK CONSTRAINT
|
CREATE TABLE Persons(P_Id int NOT NULL CHECK
(P_Id>0),LastNamevarchar(255) NOT NULL,FirstName varchar(255),Address
varchar(255),City varchar(255))
//(To check the cond’n)
For Existed table: ALTER
TABLE Persons ADD CHECK (P_Id>0)
For multiple
columns : ALTER TABLE Persons ADD CONSTRAINT chk_Person CHECK (P_Id>0
AND City='Sandnes')
ALTER TABLE Persons
To drop CHECK : DROP CONSTRAINT chk_Person |
||||
7.DEFAULT
|
CREATE TABLE Orders(
Order_Date date DEFAULT GETDATE())
For Existed table:
ALTER TABLE
Persons ALTER
COLUMN City
SET DEFAULT 'SANDNES'
drop DEFAULT:ALTER TABLE Persons
ALTER COLUMN
City DROP DEFAULT
|
||||
CREATE INDEX
UNIQUEINDEXÃ
DROP INDEXÃ
|
CREATE INDEX index_name ON table_name (column_name)
CREATE UNIQUE INDEX index_name ON table_name (column_name)
DROP INDEX table_name.index_name
|
||||
DROP
|
DROP TABLE table_name
DROP DATABASE database_name
|
||||
TRUNCATE
|
TRUNCATE TABLE table_name
|
||||
ALTER TABLE
ALTER COLUMN
|
ALTER TABLE table_name
ADD column_name datatype
ALTER TABLE table_name ATER COLUMN column_name datatype
|
||||
IDENTITY
|
CREATE TABLE Persons (P_Id int PRIMARY KEY
IDENTITY,LastName varchar(255) NOT
NULL,FirstName varchar(255),Address varchar(255),City varchar(255))
|
||||
CREATE VIEW
UPDATING VIEW
DROP VIEWÃ
|
CREATE VIEW view_name AS SELECT column_name(s)FROM
table_name
WHERE condition
CREATE OR REPLACE VIEW view_name AS SELECT
column_name(s) FROM table_name WHERE
condition
DROP VIEW view_name
|
||||
DATE FUNC’S:
|
· DATE -
format YYYY-MM-DD
· DATETIME -
format: YYYY-MM-DD HH:MM:SS
Returns the current date and time
Returns a single part of a date/time
Adds or subtracts a specified time interval from a date
Returns the time between two dates
Displays date/time data in different formats
|
||||
SELECTING NULL /NOT NULL COLUMNS
|
SELECT LastName,FirstName,Address FROM Persons
WHERE Address IS NULL/NOT NULL |
||||
IS NULL
|
NULL is treated
as specific value for the calculation purpose
|
||||
Functions
|
SELECT AVG(column_name) FROM table_name
SELECT COUNT(column_name) FROM table_name
SELECT FIRST(column_name) FROM table_name
SELECT LAST(column_name) FROM table_name
SELECT MAX(column_name) FROM table_name
SELECT MIN(column_name) FROM table_name
SELECT SUM(column_name) FROM table_name
SELECT LEN(column_name) FROM table_name
SELECT ROUND(column_name,decimals) FROM table_name
|
||||
GROUP BY
MORE THAN ONE COL’N
|
SELECT column_name, aggregate_function(column_name)
FROM table_name WHERE column_name operator value GROUP BY column_name
SELECT Customer,OrderDate,SUM(OrderPrice) FROM Orders
GROUP BY Customer,OrderDate
|
||||
HAVING
|
Instead of
Where clause ,for aggregative functions
|
||||
UPPER case
|
SELECT UPPER(column_name) FROM table_name
|
||||
LOWER case
|
SELECT LOWER(column_name) FROM table_name
|
||||
MID VALUE
|
SELECT MID(column_name,start [,length]) FROM table_name
|
||||
|
|
||||
--Create a target table
CREATE TABLE Products
(
ProductID INT PRIMARY KEY,
ProductName VARCHAR (100),
Rate MONEY
)
GO
--Insert records into target table
INSERT INTO Products
VALUES
(1, 'Tea', 10.00),
(2, 'Coffee', 20.00),
(3, 'Muffin', 30.00),
(4, 'Biscuit', 40.00)
GO
--Create source table
CREATE TABLE UpdatedProducts
(
ProductID INT PRIMARY KEY,
ProductName VARCHAR(100),
Rate MONEY
)
GO
--Insert records into source table
INSERT INTO UpdatedProducts
VALUES
(1, 'Tea', 10.00),
(2, 'Coffee', 25.00),
(3, 'Muffin', 35.00),
(5, 'Pizza', 60.00)
GO
SELECT * FROM Products
SELECT * FROM UpdatedProducts
GO
--Synchronize the target table with
--refreshed data from source table
MERGE Products AS TARGET
USING UpdatedProducts AS SOURCE
ON (TARGET.ProductID = SOURCE.ProductID)
--When records are matched, update
--the records if there is any change
WHEN MATCHED AND TARGET.ProductName <> SOURCE.ProductName
OR TARGET.Rate <> SOURCE.Rate THEN
UPDATE SET TARGET.ProductName = SOURCE.ProductName,
TARGET.Rate = SOURCE.Rate
--When no records are matched, insert
--the incoming records from source
--table to target table
WHEN NOT MATCHED BY TARGET THEN
INSERT (ProductID, ProductName, Rate)
VALUES (SOURCE.ProductID, SOURCE.ProductName, SOURCE.Rate)
--When there is a row that exists in target table and
--same record does not exist in source table
--then delete this record from target table
WHEN NOT MATCHED BY SOURCE THEN
DELETE
--$action specifies a column of type nvarchar(10)
--in the OUTPUT clause that returns one of three
--values for each row: 'INSERT', 'UPDATE', or 'DELETE',
--according to the action that was performed on that row
OUTPUT $action,
DELETED.ProductID AS TargetProductID,
DELETED.ProductName AS TargetProductName,
DELETED.Rate AS TargetRate,
INSERTED.ProductID AS SourceProductID,
INSERTED.ProductName AS SourceProductName,
INSERTED.Rate AS SourceRate;
SELECT @@ROWCOUNT;
GONotes
## open gmail and check inbox if any
new mail by linear fraemwork
Dim
iTodayMails
iTodayMails = 0
'Open GMail
SystemUtil.Run
"iexplore.exe", "http://www.gmail.com"
'Page Sync
Browser("Gmail").Page("Gmail").Sync
'Login to Gmail
Browser("Gmail").Page("Gmail").WebEdit("UserName").Set
"valid gmail
login id"
Browser("Gmail").Page("Gmail").WebEdit("Password").Set
"valid gmail
password"
Browser("Gmail").Page("Gmail").WebButton("SignIn").Click
Database Testing: How to Regression Test a Relational Database
www.agiledata.org: Techniques for
Successful Evolutionary/Agile Database Development
|
||
Relational
database management systems (RDBMSs) often persist mission-critical data
which is updated by many applications and potentially thousands if not
millions of end users. Furthermore, they implement important
functionality in the form of database methods (stored procedures, stored
functions, and/or triggers) and database objects (e.g. Java or C#
instances). The best way to ensure the continuing quality of these
assets, at least from a technical point of view, you should have a full
regression test suite which you can run on a regular basis.
In this article I argue for a fully automated, continuous regression
testing based approach to database testing. Just as agile software
developers take this approach to their application code, see Agile Testing and
Quality Strategies, we should also do the same for our
databases. |