SQL Dbms
SQL Dbms
CREATE TABLE x
(
column_name TYPE(size) CONSTRAINTS, #NOT NULL/NULL/UNIQUE/AUTO_INCREMENT
---if unique it must not have mor than one nulls
PRIMARY KEY (col_name), #(columnname datatype (size) primary key,….)
FOREIGN KEY (col_name) REFERENCES tablename(col_name), #(columnname datatype
(size) references another table name);
colname TYPE(size) Check (expression),
constraint cname foreign key (col_name)
);
SELECT col_names FROM x WHERE //jerm column sequence likbo orm show hbe
UPDATE x SET col_name=valuenew WHERE rowspecification
DELETE FROM x WHERE //kon row delete krvo
TYPE
_______________
NUMBER
VARCHAR
DATE - format YYYY-MM-DD
DATETIME - format: YYYY-MM-DD HH:MI:SS
TIMESTAMP - format: YYYY-MM-DD HH:MI:SS
YEAR - format YYYY or YY
• Int- An integer.
• Small integer- A small integer.
• Numeric (p, d)-A Fixed point number with user defined precision.
• Real, double precision- Floating point and double precision floating point
numbers with machine dependent precision.
• Float (n)- A floating point number, with precision of at least n digits.
WHERE
__________
id IN(1,2,3);
name='Suneha';
instead of WHERE or as extra write ORDER BY col_name ASC / DESC;
id=3 AND name='suneha';
id=3 OR name='suneha';
SELECT DISTINCT colname
id BETWEEN 12 AND 17;
name LIKE '%SU';
‘ ---- ‘ matches any string exactly three characters.
SELECT INTCAP() LTRIM() RTRIM(colname) UPPER() LOWER()
NVL(colname,value) LENGTH(colname),
SUBSTR(col,start,end:1 indexing)
COUNT() SUM() AVG() ROUND() MAX()// GROUP BY another column
//ex SELECT SUM(marks)
// SELECT SUM(marks) GROUP BY section here only to show less rows HAVING
SUM(marks) >30
JOINS
___________
SELECT col1 FROM x1
UNION INTERSECT MINUS
SELECT col2 FROM x2
___________________________________________________________________________________
______________
functions
---------
-----------------------------------------------------------------------------------
----------------------------------------------------------------
JOINS(interpolate table --->>>)
------
-----------------------------------------------------------------------------------
------------------------------------------------------------------
subquery
-----------
independent
_____________
dependent
____________
---ei row ta dko ebr nebo kina depends on ---- next query