《OracleDBA日常工作和职责》1.数据库环境LEO1@LEO1select*fromv$version;BANNER---------------------------------------------------------------------------
《Oracle DBA日常工作和职责》
1.数据库环境
LEO1@LEO1> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
2.用SQL计算出你所用数据库的总容量,给出SQL语句和结果。
如果要计算数据库的总容量就需要知道数据库由哪几部分组成的,然后计算每部分的容量之和即可
(1)数据文件
路径:/u01/app/oracle/oradata/LEO1/
数据文件名 字节 M
leo1_01.dbf 419438592 400M
sysaux01.dbf 639639552 610M
system01.dbf 734011392 700M
undotbs01.dbf 173023232 165M
users01.dbf 5251072 5M
我们看一下对应表空间的使用情况
LEO1@LEO1> select df.tablespace_name "表空间名",totalspace "总空间M",freespace "剩余空间M",round((1-freespace/totalspace)*100,2) "使用率%"
from
(select tablespace_name,round(sum(bytes)/1024/1024) totalspace from dba_data_files group by tablespace_name) df,
(select tablespace_name,round(sum(bytes)/1024/1024) freespace from dba_free_space group by tablespace_name) fs
where df.tablespace_name=fs.tablespace_name order by df.tablespace_name ; 2 3 4 5
表空间名 总空间M 剩余空间M 使用率%
--------------------------------------------------------------------------------------
LEO1 400 237 40.75
SYSAUX 610 31 94.92
SYSTEM 700 8 98.86
UNDOTBS1 165 137 16.97
USERS 5 4 20
(2)临时文件
路径:/u01/app/oracle/oradata/LEO1/
临时文件名 字节 M
temp01.dbf 128983040 123
我们看一下对应表空间的使用情况
LEO1@LEO1> select file_name,tablespace_name,bytes/1024/1024,user_bytes/1024/1024 from dba_temp_files;
FILE_NAME TABLESPACE_NAME BYTES/1024/1024
--------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/LEO1/temp01.dbf TEMP 123
(3)重做日志文件
路径:/u01/app/oracle/oradata/LEO1/
重做日志文件名 字节 M
redo01.log 52429312 50
redo02.log 52429312 50
redo03.log 52429312 50
三个是镜像关系,所以大小都一样
(4)控制文件
路径:/u01/app/oracle/oradata/LEO1/
控制文件名 字节 M
control01.ctl 9748480 9.29
control02.ctl 9748480 9.29
control03.ctl 9748480 9.29
三个也是镜像关系,所以大小都一样,控制文件的大小会根据数据库结构的变化而变化
(5)参数文件
路径:/u01/app/oracle/product/11.2.0/db_1/dbs
参数文件名 字节 M
spfileLEO1.ora 2560 0.003
参数文件是描述数据库属性的,记录了数据库非默认值的所有初始化参数
(6)告警日志
路径:/u01/app/oracle/diag/rdbms/leo1/LEO1/trace
告警日志 字节 M
alert_LEO1.log 2271951 2.166
告警日志记录数据库中所有的报错信息,会随着信息量的多少而变化,我们也可以清空告警日志
(7)密码文件
路径:/u01/app/oracle/product/11.2.0/db_1/dbs
密码文件名 字节 M
orapwLEO1 1536 0.002
密码文件保存着数据库管理员信息(ID passwd),只要数据库添加管理员就会在这里添加对应的信息
(8)dump文件和归档日志
Adump
Bdump
Cdump
Udump
这些都是记录数据库信息的日志文件,把它们的容量加在一起就是数据库总容量了
数据库容量公式:数据文件+临时文件+重做日志文件+控制文件+参数文件+告警日志+密码文件+……
Count:(400+610+700+165+5)+123+(50+50+50)+(9.29+9.29+9.29)+0.003+2.166+0.002=2183.041M
小结:所谓数据库就是文件的集合,那么数据库容量就是文件集合的容量。
3.用SQL计算出某个用户下所有对象的大小,给出SQL语句和结果。
我们要计算用户的所有对象就是计算一个schema的大小
段对象:凡是分配存储空间的对象就叫段对象
我最常用的用户名LEO1,下面我们就来看看这个用户的schema的所有对象
LEO1@LEO1> select owner,segment_name,segment_type,partition_name,bytes from dba_segments where owner='LEO1';
OWNER SEGMENT_NAME SEGMENT_TYPE PARTITION_NAME BYTES
------------------------------ ---------------------------------------- ------------------ -------------------- ----------

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
