Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1




|Views: 128|Likes:
Published by santhosh1212
database basics
database basics

More info:

Published by: santhosh1212 on Mar 25, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





A stored procedure is a set of SQL commands that has been compiled and stored on the databaseserver.Once the stored procedure has been "stored", client applications can execute the stored procedureover and over again without sending it to the database server again and without compiling itagain.Stored procedures improve performance by reducing network traffic and CPU load.
Stored procedures are precompiled database queries that improve thesecurity, efficiency and usability of database client/server applications. Developersspecify a stored procedure in terms of input and output variables. They thencompile the code on the database platform and make it available to aplicationdevelopers for use in other environments, such as web applications. All of the majordatabase platforms, including Oracle, SQL Server and MySQL support storedprocedures. The major benefits of this technology are the substantial performancegains from precompiled execution, the reduction of client/server traffic,development efficiency gains from code reuse and abstraction and the securitycontrols inherent in granting users permissions on specific stored proceduresinstead of the underlying database tables.SQL Server Data types
Character strings:Data typeDescriptionStorage
char(n)Fixed-length character string. Maximum 8,000 charactersnvarchar(n)Variable-length character string. Maximum 8,000 charactersvarchar(max)Variable-length character string. Maximum 1,073,741,824characters textVariable-length character string. Maximum 2GB of text data
RDBMS stands for Relational Database Management System.RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBMDB2, Oracle, MySQL, and Microsoft Access.The data in RDBMS is stored in database objects called tables.A table is a collections of related data entries and it consists of columns and rows.
The PRIMARY KEY constraint uniquely identifies each record in a database table.Primary keys must contain unique values.A primary key column cannot contain NULL values.Each table should have a primary key, and each table can have only one primary key.
A FOREIGN KEY in one table points to a PRIMARY KEY in another table.Let's illustrate the foreign key with an example. Look at the following two tables:The "Persons" table:
1HansenOlaTimoteivn 10Sandnes2SvendsonToveBorgvn 23Sandnes3PettersenKariStorgt 20StavangeThe "Orders" table:
1778953244678332245624245621 Note that the "P_Id" column in the "Orders" table points to the "P_Id" column in the "Persons"table.The "P_Id" column in the "Persons" table is the PRIMARY KEY in the "Persons" table.The "P_Id" column in the "Orders" table is a FOREIGN KEY in the "Orders" table.The FOREIGN KEY constraint is used to prevent actions that would destroy link between tables.The FOREIGN KEY constraint also prevents that invalid data is inserted into the foreign keycolumn, because it has to be one of the values contained in the table it points to.
The CREATE TABLE Statement
The CREATE TABLE statement is used to create a table in a database.
CREATE TABLE table_name(column_name1 data_type,column_name2 data_type,column_name3 data_type,
The data type specifies what type of data the column can hold. For a complete reference of allthe data types available in MS Access, MySQL, and SQL Server, go to our completeData Typesreference.
 Now we want to create a table called "Persons" that contains five columns: P_Id, LastName,FirstName, Address, and City.We use the following CREATE TABLE statement:
CREATE TABLE Persons(P_Id int,LastName varchar(255),FirstName varchar(255),Address varchar(255),City varchar(255))
The P_Id column is of type int and will hold a number. The LastName, FirstName, Address, andCity columns are of type varchar with a maximum length of 255 characters.The empty "Persons" table will now look like this:
SQL Aggregate Functions
SQL aggregate functions return a single value, calculated from values in a column.Useful aggregate functions:
AVG() - Returns the average value
COUNT() - Returns the number of rows
FIRST() - Returns the first value

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->