Friday 12 September 2014

BASIC SQL COMMANDS

Most of the database management software uses Structured Query Language. Sql has now become a standard language for accessing databases. Knowledge of basic commands always comes handy when you are programming for any software , web application or even a website that require the use of database.

CREATE DATABASE:  ” CREATE DATABASE dbname; ”      This command is used to create a new database. For example, create database invincible.  This command will create a new database with the name ‘invincible’.

USE: “USE dbname” This command is used to change the default database for your further sql queries. Master Database is the default database.

SELECT:  “SELECT columnnames FROM tablename”   This command will select the all the columns mentions after select keyword from the specified class. To see all the data in a specified table, we use “SELECT * FROM tablename “. ‘*’ represents all.

SELECT DISTINCT: “SELECT DISTINCT columnnames FROM tablename”  This command work same as the select command. But, with a difference, it eliminates the duplicate value.

WHERE: “SELECT * FROM tablename WHERE condition” Where is used to implement any condition in Sql query. For example, select student_name from studentdetail where class = 5, this will represent all the names of students who are in Class 5.

AND: “SELECT * FROM tablename WHERE condition1 AND condition2″ The command will show the result of only those data which satisfy both the commands. Example: select student_name from studentdetail where rollno = 10 and class=5. This command will show the result of those student name sudying in 5th class and has roll no. 10.

OR: “SELECT * FROM tablename WHERE condition1 OR condition2″ This command will show the result of the data which satisfies any of the given command or both the commands. For example, select student_name from studentdetail where class = 5 or class = 6. This command will show the result of all the names of student studying in 5th class and the students studying in 6th class.

No comments:

Post a Comment

Wildern Pupils if you log onto your school email account you can leave a comment via that ID.