[[email protected] ~]# su-oracle/* switch into Oracle
[[email protected] ~]$ sqlplus/as SYSDBA/* switch into SQL
Sql*plus:release 11.2.0.1.0 Production on Tuesday July 12 14:51:36 2016
Copyright (c) 1982, Oracle. All rights reserved.
Connected to the idle routine. /* Indicates that the database is not successfully started and requires a command Staerup to restart the database
Sql> Startup
The ORACLE routine has been started. /* Indicates the database started successfully
Total System Global area 849530880 bytes
Fixed Size 1339824 bytes
Variable Size 499125840 bytes
Database buffers 343932928 bytes
Redo buffers 5132288 bytes
The database is loaded.
The database is already open.
Sql> CREATE TABLE test1 (id int); /* Create a new table test1
The table is created.
Sql> Save Test1.sql/* Saves the file (saves the newly created TEST1 to the database for the next direct use)
File Test1.sql has been created
Sql> Get test1.sql/* View files
1* CREATE TABLE test1 (ID int)
sql> shutdown Immediate/* Close database
The database is closed.
The database has been uninstalled.
The ORACLE routine has been closed.
Sql> Startup
The ORACLE routine has been started.
Total System Global area 849530880 bytes
Fixed Size 1339824 bytes
Variable Size 499125840 bytes
Database buffers 343932928 bytes
Redo buffers 5132288 bytes
The database is loaded.
The database is already open.
Basic SQL Statement Operations:
/* Create a new table checks
Sql> CREATE TABLE checks (check# Int,payee char), amout decimal (14,2), remarks char (60));
The table is created.
/* Save
Sql> Save Checks.sql
File Checks.sql has been created
/* View Files
Sql> Get Checks.sql
1* CREATE TABLE checks (check# Int,payee char), amout decimal (14,2), remarks char (60))
/* Increment (add a new row of data to the table)
Sql> INSERT into checks values (2, ' Reading R.R ', 245.34, ' Train to Chicago ');
1 rows have been created.
Sql> INSERT into checks values (2, ' Ma Bell ', 200.32, ' cellular phone ');
1 rows have been created.
/* UPDATE (update the value of a property in a database table)
Sql> Update checks set check#= ' 3 ' where check#= ' 2 ' and payee= ' Ma Bell ';
1 rows have been updated.
/* and see if the above actions are updated successfully
Sql> SELECT * from checks where check#= ' 3 ';
check# Payee Amout
---------- ---------------------------------------- ----------
REMARKS
--------------------------------------------------------------------------------
3 Ma Bell200.32
Cellular phone
/* Delete (deletes data from a row in a database table)
Sql> Delete from checks where check#= ' 3 ';
1 rows have been deleted.
/* and see if the above actions were removed successfully
Sql> SELECT * from checks where check#= ' 3 ';
Row not selected
Note:
If garbled, you need to modify the ~/.bash_profile file (export nls_lang= "simplified Chinese_china. ZHS16GBK "Add to file as shown below)
[[email protected] ~]$ VIM ~/.bash_profile/* Modify File
# Get the aliases and functions
If [-f ~/.BASHRC]; Then
. ~/.bashrc
Fi
# User specific environment and startup programs
Oracle_base=/u01/app/oracle
Oracle_home= $ORACLE _base/product/11.2.0/db_1
Oracle_sid=test/* The database for this operation is test by selecting the database to which the ORACLE_SID is assigned
Path= $ORACLE _home/bin:a$path: $HOME/bin
Export Oracle_base
Export Oracle_home
Export Oracle_sid
Export PATH
Export nls_lang= "simplified Chinese_china. ZHS16GBK "/* Add this sentence can not garbled
Alias sqlplus= "Rlwrap Sqlplus"
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"~/.bash_profile" 24L, 426C
Oracle Basic Operations Command: