Viewing data in the tables

VIEW ALL ROWS AND COLUMNS:

  • The select commands used to view all columns and rows.
  • Syntax
    • select * from
  • Example:
    • select * from student;
VIEW SPECIFIC COLUMNS:


  • The select commands used to view specific column data.
  • We can specify the list of columns with select command.
  • All columns names can be separated by comma.
  • Syntax
    • select from
  • Example:
    • select rollno, name from student;
CONDITIONAL RETRIEVAL:

  • The select commands used to retrieve specific rows fro table.
  • To filtering the records we can use where clause.
  • Syntax
    • select * / from where
  • Example:
    • select rollno, name from student where city='Delhi';
REMOVING DUPLICATE ROWS:

  • The distinct command used to remove duplicate rows.
  • Syntax
    • select distinct * / from
  • Example:
    • select distinct city from student;
VIEWING STRUCTURE OF TABLE:
  • DESC stands for DESCRIBE
  • DESC command is used to view the structure of the table.
    • This commands display the structure of table with all columns.
    • Each column contains the name, data type, and size of columns.
  • Syntax
    • DESC
    • DESCRIBE
  • Example:
    • DESC Student
    • DESCRIBE Student

INSERTING DATA INTO TABLE:

  • Insert command is used to insert records into a table.
  • Using insert command, you can insert records of values for all columns or specified columns.
    • Syntax
      • insert into [(column_name1,column_name2,...)] values (exp1, exp2, exp3);
    • Example:
      • insert into student values(2,'Sarthak','Ganpat Uni','Kherwa','31-Aug-12');
      • insert into student(rollno,name) values(3,'Anita');
  • Rules:
    • They must be the same type.
    • They must stay within the limits of their particular column size.
    • There must be a one to one correspondence between selected columns.

INSERTING DATA INTO TABLE FROM ANOTHER TABLE:
  • Insert command is used to insert records into table from another table.
    • Syntax
      • insert into [(column_name1,column_name2,...)] select from ;
    • Example:
      • insert into stud as select rollno, name from student;
INSERTING DATA INTERACTIVELY:
  • '&' symbol is used to insert data interactively.
  • This symbol indicates to oracle that you want to specify a value for that column before oracle processes query.
  • Syntax:
    • insert into values [(column_name1, column_name2,...) values(&var1, &var2,....)
  • Example:
    • insert into student values(&rollno, '&name','&address','&city','&DOB');
Note: To enter characters or string or data or time values must be enclosed by a single quote before and after.


Thanks a lot for query or your valuable suggestions related to the topic.

Previous Post Next Post

Contact Form