Unit-4_Introduction to Structured Query Language
Unit-4_Introduction to Structured Query Language
Introduction to Structured
Query Language
Example:
Add Hobbies column in student table.
Alter table Student ADD Hobbies varchar2(15);
DDL command: ALTER(Cont..)
• To change datatype of column in table:
Syntax:
ALTER TABLE tablename MODIFY ColumnName datatype;
Example:
change size of Hobbies to 20.
Alter table Student MODIFY Hobbies varchar2(20);
2) string_format
The string_format is a string that determines the format that the
result string should be in.
The string_format argument is optional.
Example of to_char() with number
• Select TO_CHAR(1210.73, '9999.9') from dual;
Result: ' 1210.7'
2) format_mask
This is the format that will be used to
convert string1 to a number.
The format_mask is optional.
Example of to_number()
• Select TO_NUMBER('1210.73', '9999.99') from dual;
Result: 1210.73
• Select TO_NUMBER('546', '999') from dual;
Result: 546
• Select TO_NUMBER('23', '99') from dual;
Result: 23
Conversion function: To_date()
• TO_DATE function converts a string to a date.
• Syntax:
TO_DATE( string1 [, format_mask])
• Arguments:
String1
The string that will be converted to a date.
format_mask
Optional.
This is the format that will be used to convert string1 to a
date.
Example of To_date()
• SELECT TO_DATE('2020/09/05', 'yyyy/mm/dd') from
dual;
Result: 09/05/2020