SQL Commands
SQL Commands
SQL Commands
SQL Languages:
int
number
varchar2
decimal
date
char
Truncate:
truncate table MOVIE;
select 'The Invoice No. Of Customer Id.' + Cust_id + ' is ' + Inv_no +'
and Movie No. Is ' + cast(Movie_no as varchar) from INVOICE;
HAVING:
ALIAS
LIVESQL
SQL SERVER:
SELECT CustomerName, Address + ', ' + PostalCode + ' ' + City + ', '
+ Country AS Address
FROM Customers;
UNION
Combines results of two or more queries into. Columns must have the
same data type and there must be the same number of columns
chosen. Columns must be in the same order.
EXISTS
The EXISTS operator returns TRUE if the subquery returns one or
more records.
VIEWS
A view contains rows and columns, just like a real table. The fields in a
view are fields from one or more real tables in the database.
1) Create view:
create view HELLO as
select c.Cust_id,Fname, Title
from INVOICE i, CUST c, MOVIE m
where (Fname like 'Tina' or Fname like 'Allan') and i.Movie_no=
m.Movie_no and i.Cust_id= c.Cust_id;
select * from HELLO;
2) Alter view:
alter view HELLO as
select c.Cust_id,Fname, Title, Price
from INVOICE i, CUST c, MOVIE m
where (Fname like 'Tina' or Fname like 'Allan') and i.Movie_no=
m.Movie_no and i.Cust_id= c.Cust_id;
select * from HELLO;
Age int
);
MySQL:
ALTER UPDATE
DELETE DROP
DROP TRUNCATE
1. It removes the entire schema, 1. The TRUNCATE command is
table, domain, or constraints from used to delete all the rows from
the database. the table.
2. In the DROP command, table 2. the TRUNCATE command does
space is freed from memory. not free the tablespace from
3. In the DROP command, a view of memory.
the table does not exist. 3. While in this command, a view of
the table exists.
DELETE TRUNCATE
Next triggers,censors,functions.