DB2 Build Table:
Create table Tab_name (
field 1 type not null/default value
)
Change the type or length of a field in a table:
Alter TABLE Tab_name
alter COLUMN todolist SET DATA TYPE <DATATYPE>
simple to delete and change:
Add an article:
INSERT into Tab_name (C1,C2,C3) VALUES (",", ",")
Add multiple lines:
INSERT into Tab_name (C1,C2,C3) VALUES (', ', ', ', '), (', ', ', ', '), (' ', ' ', ', '), (', ', ', '); comma separated
Insert data from one table into another table:
Insert into TAB1 (C1,C2)
select c1,c2 from TAB2
such as:
INSERT INTO TEACHER (id,name,age)
Select Id,name, Age from STUDENT;
Modify Update:
UPDATE Table name
SET field name = ' character value ', field name = value, ...
WHERE Condition
Remove Delete
DELETE from table name
WHERE condition ...
Note: If there is no where condition, the data in the entire table will be deleted.
Delete Table by: Droptable tabname;
Find:
Select column from table where condition
can not add where
Conditional expression:
This figure is from the Internet
query removes duplicate rows: keyword distinct
SELECT DISTINCT field name 1, field name 2 from table name
To find data from multiple tables:
SELECT Field name 1, field Name 2 ... from table 1, table 2
WHERE table 1. field 1= table 2. Field 2
When the field name repeats, you can alias the table and then alias the field name.
Sub-query:
SELECT Field name 1, field Name 2 ... from table 1
where field 1= (SELECT field name from table name WHERE condition)