Oracle Learning-----Data in the action table

Source: Internet
Author: User

1. Add data to the table (Insert statement):

Syntax to add:

INSERT  into table_name (column1,column2,column3,......)      VALUES (Value1,value2,value3,...)

The fields after table_name can be omitted, except that each field of values must match the defined field.

(1). First create a table:

Sql> Create TableUserInfo (2Id Number(6,0),  3Usernamevarchar2( -),  4Userpwdvarchar2( -),  5Emailvarchar2( -),  6regdate date)7; The table was created. SQL> descUserInfo; is the name empty? type----------------------------------------- -------- ----------------------------Id Number(6) USERNAMEVARCHAR2( -) UserpwdVARCHAR2( -) EMAILVARCHAR2( -) regdate Datesql>

(2), add values to all the fields in the table:

Sql> Select *  fromUserInfo; ID USERNAME userpwd---------- -------------------- --------------------EMAIL regdate------------------------------ --------------         1Xxx123456Ltwuyanlong@163. com --September- theSQL>

Note: sysdate is the function that gets the current time;

(3), add a value to the specified field in the table:

Sql> Insert  intoUserInfo (ID,USERNAME,USERPWD)Values(2,'yyy','456123'); created1line. SQL> SelectUsername,userpwd fromUserInfo; USERNAME userpwd-------------------- --------------------Xxx123456yyy456123SQL>

(4), add a default value to the table:

Sql>SQL> Create TableUserinfo1 (2Id Number(6,0),  3RegDate Datedefaultsysdate); The table was created. SQL> Insert  intoUserinfo12(ID)Values(1); created1line. SQL> Select *  fromUserifo1;Select *  fromUserifo1*Section1line error: ORA-00942: The table or view does not exist in SQL> Select *  fromUserinfo1; ID RegDate---------- --------------         1  --September- theSQL>

Adding a default value to a table is using the name of the defaults keyword;

5. Add a default value after modifying the table:

Sql> Alter TableUserInfo2Modify Emaildefault 'No'; The table has changed. SQL> Insert  intoUserInfo (ID)Values(3); created1line. SQL> SelectId,email fromUserInfo; ID EMAIL---------- ------------------------------         1Ltwuyanlong@163. com2         3No SQL>

Where default values are not applicable:

Sql> Insert  intoUserInfo (ID, email)Values(4,'[email protected]'); created1line. SQL> SelectId,email fromUserInfo; ID EMAIL---------- ------------------------------         1Ltwuyanlong@163. com2         3No4 631464569@163. Comsql>

Oracle Learning-----Data in the action table

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.