ORACLE learning notes-add data function updates and oracle learning notes
1. Add data
/* Add data */insert into STU values ('stu0004', 'zhao yi', 18, 1, "kc0004"); insert into STU (STU_ID, STU_NAME, STU_AGE, STU_SET) values ('stu0013', 'Storage 11', 19,1 );
Note: If you do not specify the field to which the data is added, all data must be listed. If fields are listed, all fields whose constraints are not empty must be listed. Otherwise, an error is returned.
Ii. Update Data
/* Update data */update stu set STU_AGE = 19 WHERE STU_ID = 'stu0001'
Note: The data to be updated after SET is followed by a condition after WHERE.
3. Add Columns
/* ADD column */alter table stu add KC_NO varchar2 (10)
Note: The KC_NO column is added to STU. The constraint cannot be set here, unless there is no data in STU.
Iv. Functions
/* Average */select AVG (STU_AGE) as average from stu
/* Number of worthwhile rows */select COUNT (STU_ID) as number of rows from stu
Select COUNT (KC_NO) as number of rows from stu
/* Maximum */select MAX (STU_AGE) as maximum age from stu
/* Minimum value */select MIN (STU_AGE) as minimum age from stu
/* SUM */select SUM (STU_AGE) as and from stu
How does one add and update data in Oracle stored procedures?
Adding and updating data is the same way as general SQL statements. The only difference is variable and parameter passing, such
Select count (1) into v_count from table a where a. clct_day = p_clct_day;
V_count is a defined variable, and p_clct_day is the time parameter passed in by the process.
How to Use case functions in oracle databases
Select columns1, columns2.
(Case when comparison_expr1 THEN return_expr1
WHEN comparison_expr2 THEN return_expr2
ELSE return_expr3
END)
From table;
With the expr after CASE removed, comparision can be used as a function, such as an in function. Example case when salary in () then...
We learned this for reference only.