Sql*plus Beginners

Source: Internet
Author: User
Beginner 1. Sql*plus is a product of a number of commands consisting of standard SQL and Oracle Companies
2. How to paste text on the Sql*plus operator interface: Select the text you want to paste, and then press the right key when you left.
3. Just in contact with Oracle, special attention must be paid to the commit order and rollback.
4. Learn about Toad,sql*load,pl*sql and other tools.
5. Generally we are in contact with DDL and DML two kinds of commands.

The following are some commonly used statements that need to be mastered:
1. Display the current connected user
Sql> Show User

2. See which users the system has
Sql> select * from All_users;

3. New user and authorize
Sql> create User a identified by A; (default is built under System tablespace)
Sql> Grant Connect,resource to A;

4. Connect to New User
Sql> Conn a/a

5. Query all objects under current user
Sql> select * from tab;

6, establish the first table
Sql> CREATE Table A (a number);

7. Query table structure
Sql> desc A

8. Insert new record
Sql> INSERT into a values (1);

9. Inquiry record
Sql> select * from A;

10, change the record
sql> update a set a=2;

11, delete the record
Sql> Delete from A;

12. Roll Back
Sql> roll;
sql> rollback;

13. Submit
Sql> commit;

14. Exit
Sql> exit;
Sql> quit;

15. List the command statements in memory
Sql> list;

16. Save the current buffer command to file
Sql> select * from A;
Sql> save C:\filename;

17, get the command file read to the buffer
Sql> get c:\filename;

18, spool the information to the file

SQL>COL table_name for A20

Sql>col Comments for A80

Sql>set Linesize 110

Sql>spool C:\finame.txt

Sql>select table_name,comments from Dict;

. . . . . . (System query information)
Sql>spool off


19, again run the current buffer command

Sql> Set Lin 120

Sql> Select table_name from DICT where table_name like '%role% ';

table_name
------------------------------
Dba_roles
Dba_role_privs

2 rows have been selected.

Sql> L

1* Select table_name from DICT where table_name like '%role% '

Sql>/

table_name
------------------------------
Dba_roles
Dba_role_privs

2 rows have been selected.

20. Set up automatic commit
Sql> set autocommit on;

21, pseudo-table dual
Sql> Select To_char (sysdate, ' yyyy.mm.dd hh24:mi:ss ') from DUAL;
Sql> select 500+500*0.1+500/100 from DUAL;

These are some of the more commonly used statements, should be skilled grasp is, there are some not commonly used, you can use the time to check their own.
Next you should learn the data type, and you can choose the appropriate type and size for the field when you create the table.
As well as primary keys, foreign keys, unique keys, non-null keys, default values, etc. .....
Come on!!!


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.