Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts
Monday, June 3, 2013

What is SQL, Introduction of SQL, Structured Query Language


What is SQL, Introduction of SQL, Structured Query LanguageSQL :-
          SQL stands for Structured Query Language. It is a core language to interact with any Database. The SQL is used to create database, tables, views, indexes, inserting data into tables, updating data, updating existing objects structure, deleting existing objects etc.

The SQL divided into three major categories

  • DDL- The Data Defintion Language is used to create the objects like databases, tables, views and indexes etc.
  • DML - The Data Manipulation Language is used to perform manipulations on the existing objects like insert, update delete etc.
  • DCL - The Data Control Language is used to control the database like creating the new user, granting access to the users, invoke access from the users etc.

Data Definition Language :-


Thursday, March 7, 2013

Insert into Statement in SQL - How to insert records into a table, Insert data into a table


Insert into Statement in SQL - How to insert records into a table, Insert data into a table

The INSERT INTO Statement is used to insert new records or new row into a table. There are two ways to insert records into a table.

Inserting whole records into a table row:-

This syntax is used to insert the all records or columns into a table. we can not leave any blank record into a row in a table with this syntax.

Syntax:-

insert into <table_name> values(value1,value2,.........value n)

Example:-

insert into student_info values('John','M.Tech','California',5647839)


Inserting few records into a Table:-

This syntax is used to insert some values into a table row. Its not recommended you should insert all records into a table row, you can insert values which you want to insert.

Syntax:-

insert into <table_name>(column_name1,column_name2,column_name3,.......column_name n) values(value1,value2,value3,.........,value n)

Example:-

insert into student_info(stu_name,stu_address,stu_course) values('John','California','M.tech')
Tuesday, March 5, 2013

Alter Table - How to Add a column in a Table and How to Delete a column from a Table


Alter Table - How to Add a column in a Table and How to Delete a column from a Table

The Alter Table statement is used to add, delete or modify the columns of an existing table. Sometimes we need to add a column into an existing table, delete a column from an existing table or modify the structure of the columns like data type, range etc into an existing table then the Alter Table statement is very useful.  

Adding a Column into a Table:-

alter table <table_name> add <column_name datatype>

alter table student_info add (course varchar(30)

Deleting a Column from a Table:-

alter table <table_name> drop <column_name>

alter table student_info drop course

Modify a column into a Table:-


alter table <table_name> modify <column_name datatype>

alter table student_info modify (course varchar(50))



Saturday, March 2, 2013

How to Drop a Table in SQL - Truncate a Table in SQL - SQL Drop and Truncate a Table


How to Drop a Table in SQL - Truncate a Table in SQL - SQL Drop and Truncate a Table 

The drop table command in sql allows you to drop or delete an existing table from the database. It delete the all data as well as the structure of a table from the database.

Syntax for dropping a table:-

drop table <tablename>

Example:-

drop table student_record

Truncating a Table in SQL:-

The truncate command in sql allows you to delete all data from the existing table but the structure of table remain as it is.

This command is same as "delete from <table_name>"

Syntax for truncate a table

truncate table <table_name>

Example:-

truncate table Student_info
Friday, March 1, 2013

Data Types in SQL - List of Data Types in SQL, Data Types in Oracle, Data Types in MySql, MS Access Data Types


Data Types in SQL - List of Data Types in SQL, Data Types in Oracle, Data Types in MySql, MS Access Data Types
Data Types are used to store the kind of data into a table columns. Every columns in database has its own data type.

The SQL Data Types change according to the Database. I am Showing The list of common Data Types according to the Databases.

MS Access Data Types:-

Text - Text is used to store the combination of Characters maximum range is 255 characters only.
Memo - Memo is used to store the combination of characters maximum range is 65,536 characters.
Byte - Used to store the numbers range is 0 to 255.
Integer - Used to store the numbers range is -32768 to 32767.
Long - Used to store the numbers range is -2,147,483,648 to 2,147,483,647.
Double - Used to store real numbers.
Currency - Used to store the currency according to the country. you can store 15 digit's currency with 4 decimal points.
AutoNumber - Used to give the number automatically to the field usually start from 1 but you can change the starting point. 

Oracle Data Types:-


Char() - Char is used to store the combination of Characters maximum range is 2000 characters only and once the lenght is given to the column with char it is fixed.
Varchar - Varchar is used to store the combination of Characters as well the only difference b/w char and varchar is the varchar size depends upon the characters inputted. 
Currency - Used to store the currency according to the country. you can store 15 digit's currency with 4 decimal points.
AutoNumber - Used to give the number automatically to the field usually start from 1 but you can change the starting point. 









How to create a table in SQL - Syntax for creating a table in SQL, SQL Query for creating a table


How to create a table in SQL - Syntax for creating a table in SQL, SQL Query for creating a table

A table is a collection of rows and columns
Syntax for creating a Table :-

create table <table_name>(column_name1 datatype(range),column_name2 datatype(range),.................,column_nameN datatype(range))

Example for creating a Table for Students Records :-

create table student_info(stu_name varchar(30),stu_father_name varchar(30),stu_address varchar(100),stu_contact number(10))

How to Create a Database in Oracle, MySql, SQL Server - SQL query for creating a database


How to Create a Database in Oracle, MySql, SQL Server - SQL query for creating a database

Oracle provide one user for one database means here is no command for creating a database every user is a database itself in oracle.

Creation a Database into SQL Server :-

SQL Server provide the facility to creating a database graphically but you can create a database with sql query as well like this.

create database <databasename>

create database university;

Creating a Database into MySql :-


MySql provide the facility to creating a database graphically but you can create a database with sql query as well like this.



create database <databasename>

create database university;