Oracle SQL sample

Source: Internet
Author: User

To create a table:
1 --To Delete a table:2 --Delete the existing table with the same name before creating the table, ensuring that you can create a success. 3 --but this is a very dangerous operation and it can be very bad to delete a table that should not be deleted. 4 Drop Tablet_emp;5 --To Create a table:6 Create Tablet_emp7 (8Empno Number  not NULL,9EmpNamevarchar( -) not NULL,TenGendernvarchar(1) not NULL, OneAge Number  not NULL, ACreatetime DatedefaultSysdate, -IsdeleteChar(1)default('N') not NULL, -    --Create constraints (PRIMARY KEY constraint, UNIQUE constraint, check constraint) the     constraintPk_empnoPrimary Key(empno), -     constraintU_empnameUnique(empname), -     constraintC_isdeleteCheck(Isdeleteinch('Y','N') -);
View CodeInsert Record:
1 /*Inserting Records*/2 3 --Full Fill4 Insert  intot_emp5 (6 empno,7 EmpName,8 Gender,9 Age .Ten Createtime, One Isdelete A ) - Values - ( the    'x1234567', -    'Cloud Long', -    'male', -    ' -', + Sysdate, -    'N' + ); A  at --fill only two non-repeatable fields - Insert  intot_emp - ( - empno, - EmpName - ) in Values - ( to    'x1234568', +    'Zhao Zilong' -);
View CodeTo delete a record:
1 -- Deleting Records 2 Delete  from t_emp 3 where empno='x1234567';
View CodeUpdate record:
1 Update t_emp 2 set empno='x7654321'3where empno= ' x1234567 ';
View CodeQuery record:
1 Select  2 from t_emp3where rownum<=2;
View Code

Oracle SQL sample

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.