- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain about Create, Insert, Select command in structure query language (DBMS)?
Query is a question or requesting information. Query language is a language which is used to retrieve information from a database.
Let’s see some of the structure query language (sql) commands used to perform operations on databases.
Create Command
The create command is used to create table, view, index.
The syntax for the create command is as follows −
Create table tablename(col1 datatype(size), col2 datatype(size),……….colN datatype(size));
For Example,
create table student(name char(30), regno number(10), branch char(20));
Output
The output is the table created below −
Name | Regno | Branch |
Example
Use the command given below −
create table employee(ename char(30), department varchar(20), age number(10), address varchar(20), Phone number(10));
Output
The output is as follows −
Ename | Department | Age | Address | Phone |
Describe Command
The command used to describe the table is desc.
Syntax
The syntax for the describe command is as follows −
desc tablename
Example 1
Use the command given below −
desc student
Description − It describes the structure / schema of a table.
The output is as follows −
Name | NULL | Type |
---|---|---|
Name | Char(30) | |
Regno | Number(10) | |
Branch | Char(20) |
Example 2
Use the command mentioned below −
desc employee
Description − It describes the structure/ schema of a table.
The output is as follows −
Name | NULL | Type |
---|---|---|
Ename | Char(30) | |
Department | Varchar(20) | |
Age | Number(10) | |
Address | Varchar(30) | |
Phone | Number(10) |
Insert Command
The command used to insert data into the table/view/index in the database using ‘insert’.
Syntax
The syntax for the insert command is as follows −
insert into tablename values(valu1,value2,value3,……valueN);
Example
Insert into student values (‘hari’, 100,’CSE’); Output − 1 row created
Insert into student values (‘pinky’, 101,’CSE’); Output − 1 row created
Insert into student values (‘bob’, 102,’CSE’); Output − 1 row created
Insert into student values (‘bhanu’, 103,’CSE’); Output − 1 row created
Insert into student values (‘bhanu’, 103,’CSE’); Output − 1 row created
Insert into student values (‘pinky’, 101,’CSE’); Output − 1 row created
Select Command
The command used to select columns is select.
Syntax
The syntax for the select command is as follows −
select column1, column2,…….coulmnN from tablename
Example 1
select name,regno,branch from student
Or
select * from student;
Output
Name | Regno | Branch |
---|---|---|
Hari | 100 | CSE |
Pinky | 101 | CSE |
Bob | 102 | CSE |
Bhanu | 103 | CSE |
Bhanu | 103 | CSE |
Pinky | 101 | CSE |
Example 2
Use the command given below −
select distinct name from student;
Description − It displays distinct names in sorted order.
Output
Name | Regno | Branch |
---|---|---|
Bhanu | 103 | CSE |
Bob | 102 | CSE |
Hari | 100 | CSE |
Pinky | 101 | CSE |