Undergraduate
วิศวกรรมศาสตร์

SQL

1

20

0

Thiwaa

Thiwaa

Database core

PromotionBanner

コメント

コメントはまだありません。

ノートテキスト

ページ1:

DBMS Database Management System (DBMS)
•
•
เป็น polare ที่สางขึ้นเพื่อจัดเก็บ และจัดการกับฐานข้อมูลขนาดใหญ่
Primary key: provualundžiniju key wù giá chull)
Nonmush Primary Key 180 1879,
เพราะจะไม่มีข้อมูลให้แทงอื่น ๆ ที่มี Primary key ที่ข้ากัน
aphuiu
Foreign key : เป็นภาพคอลัมน์เพื่อมาดามสัมพันธ์เชื่อมข้อมูลทางอื่น และทำให้ข้อมูลใน
-
CREATE Database/Table
CREATE DATABASE [dbname];
minion Primary key vormimis, slamirnomatos
colname
dala.type tuse) constraint name
mysql> CREATE TABLE boat(
bid VARCHAR(3) NOT NULL,
bname VARCHAR(45) DEFAULT NULL,
color VARCHAR(45) DEFAULT NULL,
PRIMARY KEY (bid)
Query CK, rows affected (0.02 sec)
SQL Data Types
SQLite Storage Claes
.
null
.
.
integer
text
.
real
.
blob
.
numeric
Constraints
.
•
not null
unique
primary key
DATE TYPE
SPEC
CHAR
String (0-255)
INT
VARCHAR
String (0-255)
BIGINT
TINYTEXT
String (0-255)
FLOAT
TEXT
BLOB
MEDIUMTEXT
MEDIUMBLOB
LONGTEXT
LONGBLOB
TINYINT
SMALLINT
MEDIUMINT
Integer (-32763 to 32767)
Integer (4380608 to
8388607)
String (0-65535)
String (0-65535)
String (0-16777215)
String (0-16777215)
String (0-4294967295)
String (0-4294967295)
Integer (-128 to 127)
DOUBLE
DECIMAL
DATE
DATETIME
TIMESTAMP
DATA TYPE
SPEC
Integer (-2147483648 to 214748-
3647
Integer 9223372036854775808
to 9223372036854775807)
Decimal(precise to 23 digits)
Decimal (24 to 53 digits)
"DOUBLE" stored a string
WYYY-MM-DD
YYY-MM-DOHMMSS
YYYYMMDOHHMMSS
TIME
ENUM
One of preset options
SET
BOOLEAN
Selection of preset options
TINYINT
www
.
foreign key
.
chech
.
default
SELECT target-list
FROM
Every SQL Quary must have:
velation-list
.
SELECT specifies comlumns to be retained in result
.
WHERE qualification FROM: specifies a cross-product of tables
As alias
0
WHERE coptional): specifies selection conditions
เพื่อตั้งชื่อใหม่ให้กับ Output 104
ORDER BY: 1 output on (Default - ASC) (DESC)

ページ2:

-
SELECT CustomerId AS ID, First Name AS name from customers;
SELECT CustomerId AS ID, First Name AS name from customers ORDER BY name;
SELECT CustomerId AS ID, First Name AS name from customers ORDER BY name DESC;
UNION, INTERSECT EXCEPT Colos Union Compatible)
Left Query
Right Query
UNION
INTERSECT
Final Result
Combine rows from
both queries
Keep only rows in common to
both queries
EXCEPT
Keep rows from left query that
aree't included in the right query
Aggregate Operators
.
.
.
.
COUNT CA): The number of values in the column A
SUMCA) The sum of all values in the column A
AVGCA) The average of all values in the column A
MAX (A): The maximum of value in the column A
MIN CA): The minimum of value in the column A
rug track TIMA: Album ID
SELECT Albumld, count (*) AS [Number of tracks] FROM tracks
GROUP BY Albumld;
(26797) 925 HIMA: Album ID
SELECT Albumid, count(*) As [Number of tracks], sum (milliseconds) / 6000 AS
[Album Length (mins)] FROM tracks GROUP BY Albumld;
SELECT Albumid, count (*) AS [Number of tracks] FROM tracks GROUP
By Albumid HAVING count (*) > 25;
News