[email protected]:1521/orcl 2、 Start recording spool d: T...">

当前位置:网站首页>Common basic Oracle commands

Common basic Oracle commands

2022-06-26 01:29:00 Mixed with bean curd and

Oracle Common basic commands

1、 Command line login :sqlplus scott/tiger

sqlplus scott/[email protected]:1521/orcl

2、 Start recording spool d:\ The basic query .txt ( After executing the statement oracle Will be in d Disk create a “ The basic query .txt” file )

End closing the recording screen spool off( If you don't execute this sentence , The basic query .txt It will be an empty file )

3、 Carry out the previous item sql sentence :/

4、 notes :– The comment / The comment /

5、 View the current user :show user;

6、 The table under the current user :select * from tab;

7、 View table structure :desc emp

8、 Clear the screen :Linux:host clear
windows:host cls

9、 View row width :show linesize

10、 Set up :set linesize 120

11、 Set column width : character string :col ename( Name ) for(format)a8(a Representation string ,8 Express 8 Characters );

Numbers :col(column) sal for 9999(9 Represents a number ,4 One means 4 position )

12、 View date formats in the data dictionary :

select * from v$nls_parameters( Data dictionary table );

13、 Change the date format :

alter session|system set NLS_DATE_FORMAT=‘yyyy-mm-dd’;

14、 Set the number of records displayed on one page :

set pagesize 20

15、 View current date time :

mysql:select now();

oracle:select sysdate form dual;

16、count Another way of writing :select count(distinct deptno) from emp;

17、 Format :break on deptno skip 2

Unformatted :break on null

18、sqlplus One for sql The function of statement timing , Open statement :

set timing on(off)

19、 Create a temporary table :create global temporary table ****

20、 Execute the script :@+ File path + file name

@h:\testdelete.sql

21、 Turn off echo messages :set feedback off

22、 There are two ways to delete table records :

delete from Table name where Delete the condition

truncate table

23、 Administrator command line login :sqlplus sys/root as sysdba

24、 The recycle bin

Check the recycle bin :show recyclebin

Empty the recycle bin :purge recyclebin

Delete directly without going through the recycle bin :drop table tableName purge;

flashback drop : Operate the recycle bin :flashback table tableName to before drop

25、 to grant authorization

sys User give scott User permission to create views :grant create view to scott;

sys to scott Inquire about hr Next employees Table authority :grant select on hr.employees to scott;

sys User give scott Permission to create synonyms :grant create synonym to scott;

26、SQL Implementation plan of :

Generate execution plan :explain plan for select * from emp where deptno=10;

Print the execution plan :select * from table(dbms_xplan.display);

Determine which implementation plan is good , see cpu The usage rate of

27、oracle The output switch is off by default

open :set serveroutput on

28、desc + Package : You can view the package structure

desc dbms_output
6
Create user
CREATE USER "username"IDENTIFIED BY “password”;

User created.( The user has created )
4、 Use the following GRANT Statement grants HHZDH User permissions :
SQL> GRANT CONNECT, RESOURCE, DBA TO HHZDH;

Grant succeeded.( Create success )

5、 Log in to the new account to verify whether the user was created successfully
Use HHZDH The user account connects to the database (ORCL). When SQL Plus When prompted for user name and password , Input :HHZDH and 123456.

about Oracle 11g/12c, Use the following command :

SQL> CONNECT [email protected]
eg:connect [email protected]

You can enter commands :select username from dba_users;
View all table usernames

How to modify oracle Table user password
Enter the command :alter user lzfc2 identified by lzfc2;
modify lzfc2 The table user password of is lzfc2
eg:alter user “usename” identified by “newpassword”;
How to modify oracle Table user password
The password was successfully modified after pressing enter
name
Method 1 :
SQL> select name from v$database;
xe
Method 2 :
SQL> select instance_name from v$instance;
INSTANCE_NAME

orcl
Method 3 :

SQL> show parameter instance;
NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
active_instance_count             integer
cluster_database_instances         integer     1
instance_groups              string
instance_name                 string     XE
instance_number              integer     0
instance_type                 string     RDBMS
open_links_per_instance          integer     4
parallel_instance_group          string
parallel_server_instances         integer     1
————————————————

View login user permissions

select * from role_sys_privs;

– see Linux Version information

cat /etc/redhat-release

原网站

版权声明
本文为[Mixed with bean curd and]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206252353285944.html