Site icon IT Tutorial

Oracle SQL Tutorial -1 Introduction To Oracle SQL

Hi,

What is sql in this article? , What are the sql rules of writing? We will find answers to such questions .

WHAT IS SQL (STRUCTURED QUERY LANGUAGE) ?

SQL is not a programming language like C, JAVA, C ++ . ORACLE is a sub language used in databases such as MYSQL , SQL SERVER . SQL is a query language used to add , delete , access and update data in a database .

USAGE AREAS OF SQL

WHY CHOOSE SQL?

CLASSIFICATION OF SQL COMMANDS

SQL commands are divided into 3 sections according to their functions :

SQL WRITING RULES

CREATING A SQL TABLE

CREATE TABLE [schema] table

 (column datatype [DEFAULT expr] [ , .....] );

 

CREATE TABLE ADMIN.ISCI(

EMPLOYEE_ID NUMBER(6),

FIRST_NAME VARCHAR2(20 BYTE),

LAST_NAME VARCHAR2(25 BYTE),

HIRE_DATE DATE,

JOB_ID VARCHAR2(10 BYTE),

SALARY NUMBER(8,2)

)

In the picture you see above , I added my own worker table and my columns to this table with this query .

ADDING COMMENT TO TABLE

COMMENT ON TABLE ADMIN.ISCI 'ADMIN SEMASINDAKI ISCILER' ;

CONSTRAINTS

NOT NULL CONSTRAINT

 

CREATE TABLE ADMIN.ISCIS(

EMPLOYEE_ID NUMBER(6),

FIRST_NAME VARCHAR2(20 BYTE)NOT NULL,

LAST_NAME VARCHAR2(25 BYTE),

HIRE_DATE DATE,

JOB_ID VARCHAR2(10 BYTE),

SALARY NUMBER(8,2));

UNIQUE CONSTRAINT

 

CREATE TABLE ADMIN.ISCIM(

EMPLOYEE_ID NUMBER(6)UNIQUE,

FIRST_NAME VARCHAR2(20 BYTE),

LAST_NAME VARCHAR2(25 BYTE)

);

PRIMARY KEY CONSTRAINT

 

CREATE TABLE ADMIN.ISCIZ(

EMPLOYEE_ID NUMBER(6)CONSTRAINT E_PK PRIMARY KEY,

FIRST_NAME VARCHAR2(20 BYTE),

LAST_NAME  VARCHAR2(25 BYTE)

);

FOREIGN KEY CONSTRAINT

CHECK CONSTRAINT

 

CREATE TABLE ADMIN.ISC(

EMPLOYEE_ID NUMBER (6),

FIRST_NAME  VARCHAR2(20 BYTE),

LAST_NAME  VARCHAR2(25 BYTE),

SALARY NUMBER(8,2)CONSTARINT  S_MIN  CHECK(SALARY>1000)
);

CREATING TABLES WITH SUB QUESTIONS

ALTER TABLE

ALTER TABLE ADMIN.ISC RENAME COLUMN EMPLOYEE_ID TO EMP_ID;
ALTER TABLE ADMIN.ISC RENAME TO ISCILER;
ALTER TABLE ADMIN.ISCILER ADD (CONSTRAINT EMP_EMP_ID_PK PRIMARY KEY (EMP_ID));
ALTER TABLE ADMIN.ISCILER READ ONLY;
ALTER TABLE ADMIN.ISCILER ADD PARTITION PART VALUES('G3_201407_07');

TABLE CONSTRAINT

When Constraint DISABLE , all contraint controls on the table are removed . When ENABLE , controls are restored .

ALTER TABLE ADMIN.ISCILER ENABLE CONSTRAINT DEPT_LOC_FK;
ALTER TABLE ADMIN.ISCILER DISABLE CONSTRAINT DEPT_LOC_FK;

ALTER TABLE – SET UNUSED

ALTER TABLE <TABLE_NAME> SET UNUSED (<COLUMN_NAME>);

 ALTER TABLE <TABLE_NAME> DROP UNUSED COLUMNS;

 USER_UNUSED_COL_TABS

 ALL_UNUSED_COL_TABS

 DBA_UNUSED_COL_TABS ”

See you in my next post . 

 

Exit mobile version