ORACLE learning notes-add data function updates and oracle learning notes

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.