Uploaded by Srinivas Reddy

CLASS1

advertisement
---datatypes>Giving the infomation and spaces to the db to what kind of data it should store for the particular columns
integer-int----
number---number(P,S) (10.2)----
char---char(size)---80000 bytes--length---fixed length--static memory---alphanumerical
varchar---varchar(size)---2gb---variable length---dynamic memory---alphanumerical
float----
double
--------------------------------------------------------------
char(10)---2byte 3 byte 4 byte varchar(10)----2 3 4
char(2)---4
-------------SQL COMMANDS
DDL(DATA DEFINATION LANGUAGE)
CREATE----TO CREATE TABLE/table structure
SYNTAXT-CREATE TABLE TABLENAME (COL1 DATATYPE,COL2 DATATYPE())
ALTER(MODIFY,ADD,DROP)---TO alter the table structure
syntax---MODIFY---ALTER TABLE TABLENAME MODIFY(COL CHANGE DATATYPE)
ADD---ALTER TABLE TABLENAME ADD(WANTADDD COL DATATYPE)
TO DROP ATABLE---drop the table structure+data
RENAME---RENAME OLD_TABLENAME TO NEW_TABLENAME
ALTER TABLE TABLENAME
RENAME OLD_COL TO NEW_COL
TRUNCATE----TRUNCATE TABLE TABLENAME(only data) structure still remains
--------------------------------------------------------
-- Create table
create table demo_02 (id number(10),name varchar(10),contact_number number(10))----tablename and col not accept special char and space other than '_'
---Rename the table
Rename demo_01 to demo_02
---adding the col
Alter table demo_02 add(loc varchar(20))
----modifying the col/datatype
Alter table demo_02 modify(contact_number int)
select * from demo_02
desc demo_02
---to drop the table structure+data
drop table demo_02
truncate table demo_02
-------------DML
insert---to insert the data
syntax----insert into table_name values(value1,value2,....)
update---to update the data (set)
-----syntax---update tbale_name set col='' where col=''
delete----to delete the data
delete table_name---delete table_name where Insert into demo_02 values(3,'pavithra','9999999999')
Insert into demo_02 values (1,'pavithra','')
------udating the data
Update demo_02 set contact_number=12345 where id=2
----deleting the data
delete demo_02 where id=2---row level
delete demo_02---deleting entire data
select * from demo_02
commit
rollback;
----DRL/DQL(DATA RETEIVAL LANUAGE/DATA QUERY LANGUAGE) COMMAND
---SELECT---TO DISPLAY THE DATA
SELECT D1.ID FROM DEMO_02 D1
---ALIAS--ALTERNATIVE NAME FOR COL OR TABLE
WITHOUT SPECIFYING THE TABLE ALIAS WE CAN SPECIFY THE COL ALIAS BECUASE NO HEIRACHYAL DEPENCENT ----FILTER CONDITION---
WHERE--USED TO FILTER OUT THE DATA
SELECT * FROM DEMO_02
WHERE ID=3
Download