ORACLE basic SQL statements-add and update data functions, oraclesql

Source: Internet
Author: User

ORACLE basic SQL statements-add and update data functions, oraclesql

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 a 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 worthy 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

 


Write an SQL statement to insert new data into the oracle database

What do you mean by "Database Name" refers to the database name in oracle or the user where the table is located?
Log on to your oracle user:

ID, so you can create a sequence.
First create a sequence:
Create sequence seq_name ------- create a sequence named seq_name, which is defined by yourself
Minvalue 1 ----- the minimum value is 1, which can be customized.
Maxvalue 99999 ------- the maximum value is 99999, which can be customized
Start with 1 ------ start value 1, which can be customized
Increment by 1 ----- each growth value is 1, which can be customized
Cache 20; ---- cache size 20, customizable

Here, tablename is used to replace the DB you mentioned. you can replace it
Insert:
Insert into tablename (id, user, pass, sex, sn) values (seq_name.nextval, 'user', 'pass', 'sex', 'sn ');
Commit;

Modify:
Update tablename set sex = 'male' where user = 'zhang san ';
Commit;
------- What to update after set, and write the condition after where as needed. The most basic SQL statement.

Delete:
Delete from tablename where user = 'zhang san ';
Commit;
----------- Write the specific conditions by yourself.

I think you should read the most basic SQL textbooks.

SQL statement update in ORACLE Database

UPDATE YSC_YBK
Set a. JE = A. JE -(
Select c. JE
FROM YSC_BK B, YSC_BK_MX C
Where B. ND_ID = '123'
And B. ND_ID = '01'
And B. ID = C. YSC_BK_ID
And a. YSC_ID = C. YSC_ID
And a. BKXM_ID = C. BKXM_ID
)
Where exists (
SELECT 1
FROM YSC_BK B, YSC_BK_MX C
Where B. ND_ID = '123'
And B. ND_ID = '01'
And B. ID = C. YSC_BK_ID
And a. YSC_ID = C. YSC_ID
And a. BKXM_ID = C. BKXM_ID
)
You are missing the WHERE statement. The one you gave you yesterday is the MSSQL statement.
This should be okay in ORACLE. If you have any questions, contact us online at any time.

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.