RECORD

Record in DBMS

Generally, the database table is  viewed  as a collection of records. The term record  is often also called tuple and row in a database table. On this page, we will learn about Record in DBMS.

record in dbms

RECORD

Each record represents complete information of the specific data item, each record stores different data with the same structure

Example : For example in an employee table, we need to store the details of 10 employees then the database table will consist of 10 records every each record contains details of that particular employee i.e 1 record for storing the information of one employee

Consider a sample table ‘emp’ 

ENAMEJOBSALHIREDATEHIREDATE+2
KINGPRESIDENT500017-NOV-8119-NOV-81
BLAKEMANAGER285001-MAY-8103-MAY-81
CLARKMANAGER245009-JUN-8111-JUN-81
JONESMANAGER297502-APR-8104-APR-81
SCOTTANALYST300019-APR-8721-APR-87
FORDANALYST300003-DEC-8105-DEC-81
SMITHCLERK80017-DEC-8019-DEC-80

Table contents seven rows i.e it stores the details of all the 7 employees in 7 separate records

SQL Query to retrieve particular records  

SELECT * FROM EMP
WHERE DEPTNO=20;
Output:
4 rows selected.
EMPNOENAMEJOBMGRHIREDATESALCOMMDEPTNO
7566JONESMANAGER783902-APR-81297520
7788SCOTTANALYST756619-APR-87300020
7902FORDANALYST756603-DEC-81300020
7369SMITHCLERK790217-DEC-8080050020

Only those records corresponding to the details of Department number 20 are displayed.

record img

ROW NUM in SQL

  • The rownum clause  in SQL is used to specify the number of rcords present in a database table.
  • Each record will be added a number starting from 1 to n so that the user can easily identify the number of records present in the table.

Example

select rownum,empno,ename,job,sal,deptno 
FROM EMP;
Output:
7 rows selected.
ROWNUMEMPNOENAMEJOBSALDEPTNO
17839KINGPRESIDENT500010
27698BLAKEMANAGER285030
37782CLARKMANAGER245010
47566JONESMANAGER297520
57788SCOTTANALYST300020
67902FORDANALYST300020
77369SMITHCLERK80020

 

Displaying top N records

Suppose if you want to display the top three records present in emp table then you can use this rownum along with the relational operator.

Example

select rownum,empno,ename,job,sal,deptno 
FROM EMP
where rownum<=3;
Output:
3 rows selected.
ROWNUMEMPNOENAMEJOBSALDEPTNO
17839KINGPRESIDENT500010
27698BLAKEMANAGER285030
37782CLARKMANAGER245010

Only the first 3 records in a table or displayed

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

DBMS Tutorial banner

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription