Oracle is a database management system and a core product of Oracle Corporation. Its advantages in data security and safety control, as well as the ability of data operation across operating systems and hardware platforms. Based on the "client/server" (Client/server) system architecture.
Main Features:
1. Support multi-user, event volume transaction processing.
2. Superior performance in maintaining data security and integrity.
3. Support Distributed data processing. The databases that are published in different physical locations are connected by communication networks to form a logically unified database that accomplishes data processing tasks.
4. It is portable. Oracle can be used on multiple operating system platforms, such as Windows, Linux, and more.
Oracle Basic Concepts:
1. Database. The database here is a collection of data stored on disk and is physically represented as data files, log files, control files, and so on. is logically present in the form of a tablespace. You must first create a database before you can use Oracle. Can be created on database configuation assistant.
2. Global database name. Used to differentiate the identity of a database. It consists of a database name and a domain name, similar to the domain name in the network, so that the name of the database is unique throughout the network environment.
3. DB instance. Each database that is started corresponds to a database instance that accesses the data in the database.
4. Table space. Each database is made up of several table spaces, and all the content that a user establishes in the database is stored in the table space. A table space can consist of multiple data files, but a data file can belong to only one table space.
5. Data files. The extension is. DBF, which is the file used to store database data. A data file may store data from many tables, and data from one table can be stored in multiple data files. There is no one-to-one relationship between data files and database tables.
6. Control files. Technical exhibition name. CTL, is a binary file. A control file is a file that is necessary to start and run the database. Stores the name and location of the data file and log file. Oracle 11g contains three control files by default.
7. log files. The extension. log, which records all changes to the data, and provides a data recovery mechanism to ensure that the database is recovered after a system crash or other unexpected occurrence. During the work process, multiple log file groups are used for recycling.
8. Mode and Mode object. A pattern is a collection of database objects (tables, indexes, and so on, also known as schema objects).
Oracle data type: 1, character data type:
1) char data type. Use char when a fixed-length string is required. Length 1~2000 bytes. If no size is specified, the default is 1 bytes. If the user enters a value that is less than the specified size, the system is padded with spaces. If greater than, error.
2) VARCHAR2 data type, supports variable-length strings. The size is 1~4000 bytes. If the user enters a value that is less than the specified size and is not populated, the VARCHAR2 data type can save disk space. If VARCHAR2 want to store the corresponding number of Chinese characters according to the defined length
Example: Varchar2 (ten char)
3) NChar data type, that is, the national character set, using the same method as Char. Used to store Unicode character set types, which are double-byte character data. The minimum unit is 1 characters.
4) NVARCHAR2 is similar to nchar, only variable-length.
2. Numeric data type number:
The Number data type can store positive, negative, 0, fixed-point, and 38-letter floating-point numbers.
Syntax: Number (P,S)--Is there no limit if p,s content is not written?
P is precision, which represents the number of significant digits, between 1~38, from the first left of a number not 0, the decimal and negative numbers do not count as significant digits.
S is the range that represents the number of digits to the right of the decimal, between -84~+127.
Rule: First accurate to decimal right s bit, and rounded. If the number of valid digits of the exact value is <=p, then the error is correct.
3. Date-time data type: used to store date and time values
1) Date data type, used to store dates and time data in the table. With a fixed length of 7 bytes, each byte is stored for the century, year, month, day, time, minute, and second respectively. The function of the Sysdate function is to return the current date and time.
2) timestamp data type for storing the year, month, day, and hour, minutes, and seconds of the date. The seconds value is exactly 6 bits after the decimal, including the time zone information. The function of the Systimestamp function is to return the current date, time, and time zone.
Change the date format:
Oracle中的SQL窗口:alter session set nls date format=’YYYY-MM-DD HH24:MI:SS’;//只对当前窗口有效。
Environment variable: key: Nls_date_format
值:YYYY-MM-DD HH24:MISS
4. Cursor type, sys_refcursor type is the system cursor type provided by Oracle.
as follows, the procedure returns a cursor type:
CREATE OR REPLACE PROCEDURE get_sals(cur_salary OUT SYS_REFCURSOR)ISBEGINOPEN our_salary FOR SELECT empno, sal FROM employee;END;
After a brief introduction we start to install!!!
Prerequisites: Database package and FLASH-PLAYER-NPAPI-26.0.0.131-RELEASE.X86_64.RPM package
First, turn off firewall self-booting, and related features and enhanced security features
[[email protected] ~]# systemctl disable firewalld.service[[email protected] ~]# systemctl stop firewalld.service[[email protected] ~]# setenforce 0
Create an XFS format file system and mount it, creating the/orc directory as a mount directory
[Email protected]~] #mkfs-t XFS/DEV/SDB1
[Email protected]~] #mount/DEV/SDB1/ORC
Note: There is a need to add a hard disk of not less than 15G in the virtual machine, which will take effect after reboot.
Third, change the host name, add user address
[[email protected] ~]#vim /etc/hostname //更改主机名OracleHOSTNAME=oracle //重启虚拟机后生效[[email protected] ~]#vim /etc/hostslocal_host_ip Oracle
Iv. installation of the Software environment package
[[email protected] ~]#yum -y install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
Five, adjust the kernel parameters
[[email protected] ~]#vim /etc/sysctl.conffs.aio-max-nr = 1048576 #异步IO请求数目 推荐值是:1048576 其实它等于 1024*1024 也就是 1024K 个fs.file-max = 6815744 #打开的文件句柄的最大数量,防止文件描述符耗尽的问题kernel.shmall = 2097152 #共享内存总量 页为单位,内存除以4K所得kernel.shmmax = 4294967295 kernel.shmmni = 4096kernel.sem = 250 32000 100 128 #SEMMSL: 每个信号集的最大信号数量 SEMMNS:用于控制整个 Linux 系统中信号的最大数 SEMOPM: 内核参数用于控制每个 semop 系统调用可以执行的信号操作的数量 SEMMNI :内核参数用于控制整个 Linux 系统中信号集的最大数量net.ipv4.ip_local_port_range = 9000 65500 #用于向外连接的端口范围 net.core.rmem_default = 262144 #套接字接收缓冲区大小的缺省值net.core.rmem_max = 4194304 #套接字接收缓冲区大小的最大值net.core.wmem_default = 262144 #套接字发送缓冲区大小的缺省值net.core.wmem_max = 1048576 #套接字发送缓冲区大小的最大值[[email protected] ~]#sysctl -p //重新加载配置文件
Six, User environment configuration
[[email protected] ~]#groupadd oinstall[[email protected] ~]#groupadd dba[[email protected] ~]#useradd -g oinstall -G dba oracle[[email protected] ~]#passwd oracle //密码123123[[email protected] ~]#mkdir -p /orc/app/oracle[[email protected] ~]#chown -R oracle:oinstall /orc/app/[[email protected] ~]#chmod -R 755 /orc/app/oracle/
Vii. Oracle User Environment configuration
[[email protected] ~]#vim /home/oracle/.bash_profile umask 022ORACLE_BASE=/orc/app/oracleORACLE_HOME=/orc/app/oracle/product/12.2.0/dbhome_1/ORACLE_SID=orclNLS_LANG="SIMPLIFIED CHINESE_CHINA".UTF8PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/binLANG=zh_CN.UTF-8export PATH LANG NLS_LANG ORACLE_BASE ORACLE_HOME ORACLE_SID
Viii. Oracle User Resource limitations, using Pam_limits authentication mode
Note: The edited content here can be inserted in the last line without changing the original content.
[[email protected] ~]#vim /etc/pam.d/loginsession required /lib/security/pam_limits.sosession required pam_limits.so[[email protected] ~]#vim /etc/security/limits.conforacle soft nproc 2047 #单用户可使用的进程数量oracle hard nproc 16384oracle soft nofile 1024 #用户可打开的文件数量oracle hard nofile 65536oracle soft stack 10240 #堆栈设置[[email protected] ~]#vim /etc/profileif [ $USER = "oracle" ] then if [ $SHELL = "/bin/ksh" ] then ulimit -p 16384 #缓冲区大小 ulimit -p 65536 else ulimit -u 16384 -n 65536 #进程数 文件数 fifi
Nine, Oracle installation, the unzipped database package mounted in the/ABC directory
[[email protected] ~]#mount database /abc
X. Operating in a graphical interface
[[email protected] ~]#xhost + //以root用户在图形化界面操作[[email protected] ~]#su - oracle //切换oracle用户[[email protected] ~]$cd /abc[[email protected] abc]$export DISPLAY=:0.0[[email protected] database]$./runInstall //执行安装
installation of RPM package mounted flash
[[Email protected] ~] #rpm-IVH flash-player-npapi-26.0.0.131-release.x86_64.rpm
Use Firefox to browse open
Https://Oracle:5500/em
Login name: sys password: abc123 check: As Sysdba
Solutions that may encounter problems:
1, the installation in the process 72% or so window processing
[[email protected] ~]$su - root[[email protected] ~]#/orc/app/oraInventory/orainstRoot.sh[[email protected] ~]#/orc/app/oracle/product/12.2.0/dbhome_1/root.sh
2, error disk space is not enough
① Check the space size of the added hard disk, not less than 15G
After the ②oracle database is successfully installed, execute the./runinstall command, which can be installed again, so avoid duplicate installations here
Precautions:
1, only switch to Oracle user can install, do not install under the root user
2, change the hostname when the restart takes effect, the previous mount items need to be re-mounted
3, interface access is not logged on, you need to re-turn off the firewall and network security enhancements
[[Email protected] ~] #setenforce 0
Install the new database on Centos 7 oracle12c