You can display all the date in a table by using the select statement. By using * asterisk in a select statement it displays the data of all the columns in the table

Example 1:  select * from team;

Where team is the table name and ( * ) Asterisk is a wildcard character  which displays all the data in the table along with all the columns

oracle

Selecting Specific Columns

Example 2:

If you want to display certain columns from the team table then you need to write the name of the columns after the (*) Asterisk.Question 1) Display First_name, Sex, Age from team

Answer)        select first_name,sex,age from team;

oracle

In similar manner you can write your own statements and display the required results.

 

In the previous post we learned to create a table in oracle. Today lets insert data into the table we created. Below is the format of the table we created. first_name, last_name, sex and age are the columns in our table.

table format

So to insert data into these columns  type :

insert into team values(‘Anish’,’Sangamam’,’male’,23);

Here team is the table name. Similarly,   insert into team values(‘anish’, ‘last’, ’20’, 10);

oracle 1

Insert Values into the Table at Run-time

Inorder to insert values at run time you need to add the amperand sign before the column names and instead of putting in the values you simply type ampersand followed by the column name.

Insert into team values(‘&first_name’,’&last_name’,’&sex’,’&age’);

When you run the query it will ask you for the firstname, lastname,sex and age.

 

 

Today, I would like to share what I have learned while studying oracle.  I’m not going by the books right now as in the books you would learn on how to fetch data from the data base using the select statement but I’m starting of with creating a table.

Before we start, you need to have knowledge about the commonly used data types.  They are char, varchar, number and date. To get more information on data types and their size read Oracle Data Types.

Syntax to Create a Table :

create table tablename (“column1″ “data type” [constraint], “column1″  ‘datatype'[constraint], “column1″ ‘datatype’ [constraint], “column1″  ‘datatype’ [constraint]);

  • “Constraint”  –  we use constraints to limit the type of data that go into a table

Exercise 1

create table team (first_name varchar(20), last_name varchar(20) , sex varchar(10), age varchar(99));

Here team is the tablename , first_name is the column, varchar is the datatype and the values in parenthesis are constraints

oracle 1

That’s how you create a table.  you can create your own table. Check out another example

Example:

create table linkinpark (first_name varchar(20), last_name varchar(20));