-
Notifications
You must be signed in to change notification settings - Fork 0
14. SQL Commands Part 6
code: Create table sha_emp ( empno number(3), ename varchar(10), sal number(8,2) );
[Note: In table creation we have to specify what kind of data we are inserting in the table. It means we have to specify which column holds which type of data.]
Ans: There are different types of data in SQL:-
- Number Type- Where we can store numeric value like 0-9 and decimal.
- Character Type- Like A-z, a-z and special character like #, @,!, etc. and numbers as well 0-9.
- Date Type- In this data type we can insert date, like in "dd-mm-yyyy" format.
- Raw Type- Where we can store binary data like 0 and 1.
Ans: Number is the data type of the column named empno, while '(3)' represents the number of digits we can store in empno. Here (3) means that we can store any number from 0 to 999 can be stored in empno.

Ans: It means the column ename accepts character type value. It accepts value that is of 10bytes. Using this datatype provides each character type value 10 bytes of memory space.
For example the name 'RAJ' takes 3 bytes the rest 7 bytes remain unused.
Ans: Varchar(10) gives us a maximum of 10 bytes space. For example RAJ name has 3 characters so it takes 3 bytes of memory space, the rest 7 bytes of unused space is freed up. So only 3 bytes space is used.
Ans: Varchar has only 2000 bytes of total memory space but Varchar2 can store up to 4000 bytes of recored, value o characters for every individual record. Now a days we use Varchar2.
Ans: It means the number will have 8 digits in which 2 digits will be decimal place.
code: alter table sha_emp rename col sal to salary;
code: alter table sha_emp add deptno number(3);