SQL Queries as you already know from previous post is the essential of Database Management System (DBMS). In this post we are going to learn some of the very basic SQL Queries that are commonly used. Let’s see these SQL Queries one by one.
Most Commonly used SQL Queries
1. Create a Table
To create table the command used is create table. Syntax is as follows:
create table table-name(column1 datatype, column2 datatype, column3 datatype….,columnn datatype);
E.g.
create table employees(name varchar2(25), employee_id number(5), salary number(10));
2. Insert values into table
Inserting values into a table is done by using insert command. Syntax is as follows:
insert into table-name values(“value1”,value2,value3);
E.g.
insert into employees values(“John”,12545,25000);
Here the name is taken into inverted commas as except number, we use all the values into inverted commas.
3. Display Table
Display a table is quite easy. To display a table along with its all columns, select command is used. Syntax is as follows:
select * from table-name;
E.g.
select * from employees;
Running the very above command will display the whole table, that’s why * is used. To display any specific column or multiple specific columns, * is replaced by column name.
For example: select name,salary from employees;
4. Describe Table
To show the names of column along with their datatypes the command we use is desc or describe. It will show the complete description of your table. Syntax is as follows:
desc table-name; or describe table-name;
E.g.
desc employees; or describe employees;
These are some of the very common and basic SQL Queries generally used. I hope that you will be now able to understand the SQL Queries without any difficulty. If you want to practice these SQL Commands you can download Oracle 11g which is the latest edition from Oracle directly from their website. In the next post we will discuss about the constraints used in SQL Queries.