sql_cmds2
sql_cmds2
Using expressions
■ To increase in Update
the gross pay of all employees
by Rs.900/-
□ UPDATE employee SET gross = gross + 900;
□ To double the gross pay of employees
of grade ‘E3’ and ‘E4’.
Updating to NULL values
□ To insert NULL values for grades ‘E4’.
■ UPDATE employees SET grade = NULL
WHERE grade = ‘E4’;
CREATE VIEW
□ CREATE VIEW taxpayee AS SELECT *
FROM employee
WHERE gross>8000;
□ To query the view
■ SELECT * FROM taxpayee;
Some built in functions
□ Lower (character- expression)
□ Upper (character- expression)
□ Replicate (char-expn, no-of-times)
□ Substr (expn, startpos, no-of-chars)
□ getdate()
Built-in functions can work on dual
tables.
Dual tables are default tables with only
one row and one column
□ Select lower (“Hello”) from dual;
□ Select upper(“friends”) from dual;
□ Select replicate (“#”, 4) from dual;
□ Select substr (“pointer”, 3, 2) from
dual;
Alter table
□ Change definition of existing table
□ Add a column
■ Alter table <table name> ADD <column
name><data type><size>;
□ Modify existing column
■ Alter table <tablename> modify
(columnname newdatatype (newsize));
Drop table
□ Drops a table from database
□ A table with rows cannot be dropped
■ DELETE from items;
■ DROP table items;
□ To delete a view
■ Drop view taxpayee;