[{"content":"Hey everyone!\nToday I wanted to cover a very important topic that caused me some confusion when I first started studying. I only got clarity on it when I had to implement it in a real project.\nWhen designing networks on AWS, one of the most important decisions is defining how different environments will communicate securely, scalably, and cost-effectively.\nAWS offers several options for private connectivity between resources, but three services tend to generate frequent confusion:\nVPC Peering AWS Transit Gateway AWS PrivateLink At first glance, they seem to solve the same problem, but each one was built for completely different scenarios.\nIn this article we\u0026rsquo;ll analyze when to use each solution, their advantages, limitations, and practical examples from the day-to-day work of cloud architects.\nPresenting the problem Imagine a company with the following environments:\nProduction Account Staging Account Development Account Security Account Shared Services Account Each environment has its own VPC and now there is a need for communication between them. The question is:\nHow do you connect these VPCs the right way?\nThe answer depends on the purpose of the communication.\nNot every situation calls for connecting the entire network. In many cases it is enough to expose just one specific service.\nThat is exactly where the differences between Peering, Transit Gateway, and PrivateLink come into play.\nVPC Peering VPC Peering creates a direct private connection between two VPCs. After the connection is created, instances can communicate using private IP addresses.\nHow it works VPC A \u0026lt;-------\u0026gt; VPC B Traffic stays within the AWS network and does not travel over the internet.\nWhen to use it Peering works best when there are only a few VPCs that need to communicate. Examples:\nA Production environment accessing a Database VPC Two applications that share internal services Simple communication between different accounts Advantages Simple to set up Low latency No single point of failure No additional appliance or gateway required Limitations No transitive routing Consider:\nVPC A \u0026lt;--\u0026gt; VPC B VPC B \u0026lt;--\u0026gt; VPC C VPC A cannot reach VPC C through VPC B.\nYou need to create another Peering:\nVPC A \u0026lt;--\u0026gt; VPC C Exponential growth With just a few VPCs it works great, but imagine 20 VPCs fully interconnected.\nThe number of connections grows quickly.\nN x (N-1) / 2 20 VPCs = 190 Peerings\nManagement becomes complex.\nReal-world scenario A company has:\nApplication VPC Database VPC Only these two networks need to talk to each other.\nIn this case, VPC Peering is usually the simplest and most cost-effective solution.\nAWS Transit Gateway Transit Gateway was built to solve the scaling problem of Peering.\nIt works as a central connectivity hub.\nHow it works VPC A | | VPC B ---- TGW ---- VPC C | | VPC D All VPCs connect to the Transit Gateway and routing happens through it.\nWhen to use it Ideal when there are many VPCs. Examples:\nMulti-account environments AWS Organizations Landing Zones Large enterprise environments Advantages Scalability Adding a new VPC requires only a new attachment.\nThere is no need to create dozens of Peerings.\nTransitive routing Unlike Peering:\nVPC A -\u0026gt; TGW -\u0026gt; VPC B VPC A -\u0026gt; TGW -\u0026gt; VPC C All of them can communicate as allowed by the route tables.\nIntegration with on-premises networks The Transit Gateway can aggregate connections from:\nSite-to-Site VPN AWS Direct Connect SD-WAN Governance Very useful for platform teams and Cloud Centers of Excellence.\nEnables centralized connectivity control.\nLimitations Cost Charges apply for:\nAttachments Processed traffic volume For small environments it may cost more than Peering.\nComplexity Requires understanding of:\nTGW Route Tables Attachments Traffic segmentation Real-world scenario A company has:\n50 AWS accounts Production environment Staging Development Security Shared Services Creating Peerings between all VPCs would be unmanageable. Transit Gateway becomes the natural architecture.\nAWS PrivateLink PrivateLink solves a different problem.\nIt was not built to connect networks — it was built to expose services. This is the key difference that often confuses certification candidates.\nHow it works Imagine there is an API running in VPC A.\nVPC B needs to consume that API.\nWith PrivateLink:\nConsumer (VPC B) | | Endpoint | | PrivateLink | | NLB | | Service (VPC A) The consumer accesses only the service — it does not gain access to the entire network.\nWhen to use it Whenever you want to share a service without sharing the VPC.\nExamples:\nInternal APIs SaaS services Corporate databases Shared tools Advantages Smaller attack surface The client cannot see:\nSubnets Routes Internal resources Only the published service.\nIsolation There is no full connectivity between VPCs.\nOnly access to the defined endpoint.\nCross-account sharing Widely used by SaaS providers.\nLimitations Does not replace network connectivity If you need to access multiple resources in a remote VPC, PrivateLink is probably not the right solution.\nRequires an NLB The published service normally sits behind a Network Load Balancer.\nThis adds components and costs.\nReal-world scenario A central team provides a corporate authentication service.\nDozens of AWS accounts need to consume that service. Granting full VPC access would be a security risk.\nWith PrivateLink, each consumer accesses only the required API.\nQuick comparison Feature VPC Peering Transit Gateway PrivateLink Connects full networks Yes Yes No Shares only a single service No No Yes Scales to dozens of VPCs No Yes Yes Transitive routing No Yes Not applicable On-premises integration Limited Excellent No Complexity Low Medium/High Medium Best for Few VPCs Many VPCs Sharing services What tends to show up on the certification exam A simple way to remember:\nFew VPCs? Use VPC Peering.\nMany VPCs? Use Transit Gateway.\nNeed to share only one application or API? Use PrivateLink.\nConclusion The choice between VPC Peering, Transit Gateway, and PrivateLink does not depend solely on connectivity, but mainly on the desired architectural model.\nVPC Peering is excellent for simple, direct scenarios.\nTransit Gateway becomes essential when the number of VPCs grows and connectivity management needs to be centralized.\nPrivateLink is the best option when the goal is to share specific services without exposing the entire network.\nIn modern enterprise projects it is common to find all three services coexisting:\nTransit Gateway connecting corporate environments VPC Peerings in specific low-complexity scenarios PrivateLink exposing APIs and shared services across accounts Understanding this distinction is fundamental both for passing the AWS Solutions Architect Associate certification and for building scalable, secure architectures in the real world.\n","permalink":"https://www.leocardozo.com/en/posts/vpc-peering-tgw-privatelink/","summary":"\u003cp\u003eHey everyone!\u003c/p\u003e\n\u003cp\u003eToday I wanted to cover a very important topic that caused me some confusion when I first started studying. I only got clarity on it when I had to implement it in a real project.\u003c/p\u003e\n\u003cp\u003eWhen designing networks on AWS, one of the most important decisions is defining how different environments will communicate securely, scalably, and cost-effectively.\u003c/p\u003e\n\u003cp\u003eAWS offers several options for private connectivity between resources, but three services tend to generate frequent confusion:\u003c/p\u003e","title":"Difference between VPC Peering, Transit Gateway, and PrivateLink"},{"content":"When a company starts its journey on AWS without the support of a consultancy or with an inexperienced team, everything usually begins in a single account. The first services are deployed quickly, teams have administrative access, and the main concern is getting workloads into production.\nIt was no different for us.\nWhen we identified the opportunity to start our cloud journey, even with some external support, we didn\u0026rsquo;t see the need for a multi-account environment.\nHowever, as the environment grew, we began to face new challenges:\nHow do we separate production and staging environments? How do we track costs per business unit? How do we prevent users from creating resources outside corporate standards? How do we enforce governance without limiting team productivity? It was the need to address these questions that led me to dive deeper into AWS Organizations — and it turned out to be a foundational piece of the puzzle. In this article, we\u0026rsquo;ll look at how to structure multiple AWS accounts from the ground up, real-world examples of Service Control Policies (SCPs), and the main governance practices used in enterprise environments.\nWhat is AWS Organizations? AWS Organizations is a service that allows you to centrally manage multiple AWS accounts. Instead of administering each account individually, you can group them into a single organization and apply governance policies at scale.\nIn practice, this enables:\nCentralized billing Access delegation across teams Security controls Enforcement of corporate policies Environment isolation The main advantage is that each account remains an independent security boundary, reducing the impact of operational mistakes and misconfigurations.\nThe most common mistake: separating everything by VPC only Many companies start their architecture by creating separate VPCs for different environments:\nProduction Staging Development While this works initially, the approach has limitations because all resources continue to share:\nService quotas Billing IAM Global configurations Furthermore, an administrative mistake can affect all environments simultaneously. That\u0026rsquo;s why AWS recommends using multiple accounts as the primary unit of isolation.\nStructuring an AWS Organization from scratch A simple and efficient structure for small and medium-sized businesses can follow the model below:\nRoot │ ├── Security OU │ ├── Log Archive │ └── Security Tooling │ ├── Network OU │ └── Networking Hub │ ├── Shared Services OU │ ├── Sandbox │ └── Shared Services │ ├── Workloads OU │ ├── DEV │ ├── HML │ └── PRD │ └── Management Account Security OU Contains accounts responsible for:\nAWS Security Hub\nAWS GuardDuty\nAWS Config\nAWS IAM Identity Center\nLog centralization\nNetwork OU Responsible for shared networking services:\nTransit Gateway\nDirect Connect\nCorporate DNS\nBackup tools\nMonitoring tools\nWorkloads OU Hosts the workloads (PRD, DEV, etc.).\nShared Services OU Contains Sandbox environments and shared services. Typically has more flexible policies to allow experimentation.\nManagement Account Each critical application can have its own account, making it easier to manage:\nGovernance Costs Security Auditing Cost control with multiple accounts One of the biggest benefits of AWS Organizations is financial visibility. Without multiple accounts, identifying who is consuming resources becomes complex. With a well-organized structure, however, you can quickly answer questions such as:\nHow much did the production environment spend this month? Which application is generating the most cost? Which team increased its storage consumption? In addition, Consolidated Billing allows you to consolidate all organization charges into a single invoice, significantly simplifying financial management.\nUnderstanding the role of SCPs A common misconception is thinking that an SCP grants permissions. In fact, it does the opposite. A Service Control Policy defines the maximum boundary of what can be executed within an account. Even if a user has administrative permissions, an SCP can still block certain actions. Think of an SCP as a corporate guardrail layer.\nExample 1: Block CloudTrail deletion A common practice is to prevent users from disabling audit mechanisms.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;cloudtrail:DeleteTrail\u0026#34;, \u0026#34;cloudtrail:StopLogging\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34; } ] } This control significantly reduces the risk of losing traceability during incidents.\nExample 2: Restrict to approved regions Many organizations operate only in specific regions. An SCP can block deployments outside those locations.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;DenyOutsideApprovedRegions\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;NotAction\u0026#34;: [ \u0026#34;iam:*\u0026#34;, \u0026#34;route53:*\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34;, \u0026#34;Condition\u0026#34;: { \u0026#34;StringNotEquals\u0026#34;: { \u0026#34;aws:RequestedRegion\u0026#34;: [ \u0026#34;sa-east-1\u0026#34;, \u0026#34;us-east-1\u0026#34; ] } } } ] } This policy helps prevent resources from being accidentally created in unapproved regions.\nExample 3: Prevent backup deletion One of the most valuable SCPs in enterprise environments.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;backup:DeleteBackupVault\u0026#34;, \u0026#34;backup:DeleteRecoveryPoint\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34; } ] } This type of protection is extremely useful in ransomware scenarios and disaster recovery.\nExample 4: Block Sandbox accounts from creating expensive resources Many companies create Sandbox accounts for experimentation. Without controls, users can provision very large instances or high-cost services. An SCP can limit the creation of certain resource types and reduce financial waste.\n{ \u0026#34;Version\u0026#34;: \u0026#34;2012-10-17\u0026#34;, \u0026#34;Statement\u0026#34;: [ { \u0026#34;Sid\u0026#34;: \u0026#34;DenyExpensiveEC2Instances\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;Action\u0026#34;: \u0026#34;ec2:RunInstances\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:ec2:*:*:instance/*\u0026#34;, \u0026#34;Condition\u0026#34;: { \u0026#34;StringNotEquals\u0026#34;: { \u0026#34;ec2:InstanceType\u0026#34;: [ \u0026#34;t3.micro\u0026#34;, \u0026#34;t3.small\u0026#34;, \u0026#34;t3.medium\u0026#34;, \u0026#34;t2.micro\u0026#34;, \u0026#34;t2.small\u0026#34; ] } } }, { \u0026#34;Sid\u0026#34;: \u0026#34;DenyExpensiveRDSInstances\u0026#34;, \u0026#34;Resource\u0026#34;: \u0026#34;arn:aws:rds:*:*:db:*\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;Action\u0026#34;: \u0026#34;rds:CreateDBInstance\u0026#34;, \u0026#34;Condition\u0026#34;: { \u0026#34;StringNotEquals\u0026#34;: { \u0026#34;rds:DatabaseClass\u0026#34;: [ \u0026#34;db.t3.micro\u0026#34;, \u0026#34;db.t3.small\u0026#34;, \u0026#34;db.t3.medium\u0026#34; ] } } }, { \u0026#34;Sid\u0026#34;: \u0026#34;DenyExpensiveServices\u0026#34;, \u0026#34;Effect\u0026#34;: \u0026#34;Deny\u0026#34;, \u0026#34;Action\u0026#34;: [ \u0026#34;redshift:CreateCluster\u0026#34;, \u0026#34;elasticmapreduce:RunJobFlow\u0026#34;, \u0026#34;sagemaker:CreateTrainingJob\u0026#34;, \u0026#34;sagemaker:CreateEndpoint\u0026#34; ], \u0026#34;Resource\u0026#34;: \u0026#34;*\u0026#34; } ] } Governance beyond SCPs Although SCPs are important, they represent only one part of a governance strategy.\nA mature architecture typically includes:\nService Function AWS Config Monitors resource compliance AWS Security Hub Centralizes security alerts AWS GuardDuty Detects suspicious activity IAM Identity Center Manages identity AWS Backup Centralizes backups Best practices for enterprise environments After working with multi-account environments, a few recommendations stand out:\nDo not use the Management account to host workloads. Keep a dedicated account for logs and auditing. Use OUs to reflect business policies, not just departments. Apply SCPs in a controlled manner initially to avoid unexpected impact. Centralize identity management through IAM Identity Center. Implement a mandatory tagging strategy from the very beginning. Automate account creation using AWS Control Tower whenever possible. Regularly review unused accounts and Sandbox environments. Conclusion AWS Organizations is much more than a tool for grouping accounts. It represents the foundation for a scalable strategy for security, governance, and financial management within AWS.\nCompanies that properly structure their organization from the start avoid common problems related to access, auditing, costs, and compliance.\nThe combination of multiple accounts, well-defined Organizational Units, and carefully planned SCPs creates a solid foundation for the long-term growth of the platform.\nThe sooner this structure is implemented, the less effort it will take to keep the environment organized and secure as new applications and teams are onboarded.\n","permalink":"https://www.leocardozo.com/en/posts/aws-organizations-na-pratica/","summary":"\u003cp\u003eWhen a company starts its journey on AWS without the support of a consultancy or with an inexperienced team, everything usually begins in a single account. The first services are deployed quickly, teams have administrative access, and the main concern is getting workloads into production.\u003c/p\u003e\n\u003cp\u003eIt was no different for us.\u003c/p\u003e\n\u003cp\u003eWhen we identified the opportunity to start our cloud journey, even with some external support, we didn\u0026rsquo;t see the need for a multi-account environment.\u003c/p\u003e","title":"AWS Organizations in Practice"},{"content":"Lessons Learned Deploying AWS Direct Connect + Transit Gateway Hybrid environments have moved from being the exception to becoming part of the strategy for many companies. Integrating on-premises datacenters with the cloud requires much more than simply provisioning resources in the cloud — it demands a deep understanding of networking, routing, and connectivity.\nWorking recently on a scenario using AWS Direct Connect integrated with AWS Transit Gateway made it even clearer how networking knowledge makes a real difference in the stability and correct operation of an architecture.\nThe project seemed straightforward at first: allow communication between on-premises environments and multiple VPCs in AWS through a private connection. However, as the topology evolved, small networking details began to directly impact how the environment functioned.\nA few points that proved critical during the configuration:\nProper planning of CIDR blocks to avoid network overlap. Understanding the routing flow between:\nSubnet Route Tables Transit Gateway Route Tables TGW Propagations and Associations On-premises environment routes Controlling asymmetric traffic, especially when a firewall exists between environments. Understanding how Direct Connect forwards traffic through the Virtual Interface (VIF) and BGP. The need to align routes between the cloud and the datacenter to avoid scenarios where:\nthe instance can reach the gateway, but cannot reach the on-premises environment. Understanding the difference between connectivity within the VPC and hybrid connectivity flowing through the Transit Gateway.\nOne interesting observation is that, in many cases, the problem is not in AWS itself, but in traditional networking concepts:\nreturn route, incorrect propagation, stateful firewall, NAT, MTU, traffic asymmetry, missing BGP advertisements. During testing, for example, it was possible to validate scenarios where:\nthe EC2 instance could reach the Transit Gateway interfaces, the Direct Connect was operational, but traffic was not returning correctly from the on-premises environment due to a missing return route. This kind of situation reinforces something important: the cloud does not eliminate the need for infrastructure and networking knowledge. In practice, it demands an even deeper understanding of these concepts.\nAWS Transit Gateway greatly simplifies building centralized architectures, especially in multi-VPC and hybrid scenarios, but it also adds a new routing layer that needs to be thoroughly understood.\nSome key takeaways from this project:\nAlways validate the complete round-trip traffic flow. Clearly map all route tables involved. Document TGW propagations and associations. Use tools such as: traceroute, Reachability Analyzer, VPC Flow Logs, tcpdump, end-to-end connectivity tests. Think through the topology before implementation to avoid unnecessary complexity. In the end, hybrid projects demonstrate how classic networking knowledge remains extremely relevant even in modern cloud computing environments.\nAWS, Direct Connect, and Transit Gateway are powerful tools — but the foundation is still networking.\n","permalink":"https://www.leocardozo.com/en/posts/redes-hibridas/","summary":"\u003ch2 id=\"lessons-learned-deploying-aws-direct-connect--transit-gateway\"\u003eLessons Learned Deploying AWS Direct Connect + Transit Gateway\u003c/h2\u003e\n\u003cp\u003eHybrid environments have moved from being the exception to becoming part of the strategy for many companies. Integrating on-premises datacenters with the cloud requires much more than simply provisioning resources in the cloud — it demands a deep understanding of networking, routing, and connectivity.\u003c/p\u003e\n\u003cp\u003eWorking recently on a scenario using AWS Direct Connect integrated with AWS Transit Gateway made it even clearer how networking knowledge makes a real difference in the stability and correct operation of an architecture.\u003c/p\u003e","title":"The Importance of Networking Knowledge in Hybrid Environments"},{"content":"Hey everyone!\nMy name is Leonardo Cardozo, and I created this blog to share knowledge, document my learning journey, and give back to the tech community that has helped me so much throughout my career.\nI have over 15 years of experience in Information Technology, working with infrastructure, networking, virtualization, backup and disaster recovery solutions, Linux and Windows administration, and enterprise environments. Throughout my journey, I\u0026rsquo;ve had the opportunity to participate in projects involving datacenter operations, high availability, infrastructure modernization, and cloud migration for services and resources.\nToday, my primary focus is Cloud Architecture, AWS, and DevOps practices. I am constantly sharpening my skills in Infrastructure as Code (Terraform), CI/CD pipelines, automation, containers, Kubernetes, and cloud-native architectures.\nHere, you will find technical articles, hands-on labs, and real-world, day-to-day experiences from enterprise environments, covering both Cloud Native and on-premises technologies.\nCurrent Tech Stack AWS Terraform Docker Github Actions Kubernets Linux Redes Other Technologies I Work With VMware Zabbix Servidores Windows Veeam Backup \u0026amp; Replication Why I Started This Blog For a long time, I waited for the \u0026ldquo;perfect\u0026rdquo; moment to share content because I didn\u0026rsquo;t think it was relevant enough. But I learned from a few peers that there is no perfect moment, and all content matters. If you can help just one person, the world becomes a better place.\nIf this content helps you at any point in your career, I’d like to encourage you to do the same.\nThank you for visiting my blog! Feel free to connect with me on LinkedIn or GitHub, or drop me an email at: contato@leocardozo.com.\n## UBUNTU \u0026#34;I am because we are; and since we are, I am.\u0026#34; ","permalink":"https://www.leocardozo.com/en/about/","summary":"\u003cp\u003eHey everyone!\u003c/p\u003e\n\u003cp\u003eMy name is Leonardo Cardozo, and I created this blog to share knowledge, document my learning journey, and give back to the tech community that has helped me so much throughout my career.\u003c/p\u003e\n\u003cp\u003eI have over 15 years of experience in Information Technology, working with infrastructure, networking, virtualization, backup and disaster recovery solutions, Linux and Windows administration, and enterprise environments. Throughout my journey, I\u0026rsquo;ve had the opportunity to participate in projects involving datacenter operations, high availability, infrastructure modernization, and cloud migration for services and resources.\u003c/p\u003e","title":"About Me"},{"content":"Tutorial: Tablespace Management in Oracle Database What is a Tablespace? A tablespace is the logical storage unit in Oracle Database. It logically groups data segments (tables, indexes, etc.) and is physically composed of one or more datafiles on the operating system.\nEvery Oracle database has at least the following default tablespaces:\nTablespace Description SYSTEM Data dictionary and Oracle internal objects SYSAUX Auxiliary components (AWR, statspack, etc.) TEMP Temporary operations (sorts, joins, group by) UNDOTBS1 Undo data storage (rollback) USERS Default tablespace for user objects Listing Tablespaces List all tablespaces in the database SELECT tablespace_name, status, contents, logging, extent_management, segment_space_management FROM dba_tablespaces ORDER BY tablespace_name; List datafiles associated with each tablespace SELECT tablespace_name, file_name, bytes / 1024 / 1024 AS size_mb, autoextensible, maxbytes / 1024 / 1024 AS max_size_mb FROM dba_data_files ORDER BY tablespace_name, file_name; List tempfiles (temporary tablespaces) SELECT tablespace_name, file_name, bytes / 1024 / 1024 AS size_mb, autoextensible FROM dba_temp_files ORDER BY tablespace_name; Checking Usage and Free Space View free space per tablespace SELECT df.tablespace_name AS tablespace, ROUND(df.total_mb, 2) AS total_mb, ROUND(fs.free_mb, 2) AS free_mb, ROUND(df.total_mb - fs.free_mb, 2) AS used_mb, ROUND((df.total_mb - fs.free_mb) / df.total_mb * 100, 2) AS pct_used FROM (SELECT tablespace_name, SUM(bytes) / 1024 / 1024 AS total_mb FROM dba_data_files GROUP BY tablespace_name) df JOIN (SELECT tablespace_name, SUM(bytes) / 1024 / 1024 AS free_mb FROM dba_free_space GROUP BY tablespace_name) fs ON df.tablespace_name = fs.tablespace_name ORDER BY pct_used DESC; Warning: Tablespaces exceeding 85% usage require immediate attention to avoid errors such as ORA-01653: unable to extend table.\nView full details including autoextend SELECT d.tablespace_name, d.file_name, ROUND(d.bytes / 1024 / 1024, 2) AS current_size_mb, d.autoextensible, ROUND(d.maxbytes / 1024 / 1024, 2) AS max_size_mb, ROUND(f.bytes / 1024 / 1024, 2) AS free_space_mb FROM dba_data_files d LEFT JOIN dba_free_space f ON d.file_id = f.file_id ORDER BY d.tablespace_name; Increasing Tablespace Size There are two main ways to increase a tablespace:\nResize an existing datafile (resize) Add a new datafile to the tablespace Option 1: Resize an existing datafile Use this command when you want to increase the size of an already existing file:\n-- Syntax ALTER DATABASE DATAFILE \u0026#39;\u0026lt;full_file_path\u0026gt;\u0026#39; RESIZE \u0026lt;new_size\u0026gt;; -- Example: increase to 2 GB ALTER DATABASE DATAFILE \u0026#39;/u01/oradata/ORCL/users01.dbf\u0026#39; RESIZE 2048M; Verify the correct datafile path using the dba_data_files query before executing.\nOption 2: Increase a temporary tablespace For TEMP type tablespaces, use TEMPFILE instead of DATAFILE:\nALTER DATABASE TEMPFILE \u0026#39;/u01/oradata/ORCL/temp01.dbf\u0026#39; RESIZE 1024M; Enabling Autoextend Autoextend allows Oracle to automatically expand the datafile when space runs out, up to a defined limit.\nEnable autoextend on an existing datafile -- Syntax ALTER DATABASE DATAFILE \u0026#39;\u0026lt;file_path\u0026gt;\u0026#39; AUTOEXTEND ON NEXT \u0026lt;increment\u0026gt; MAXSIZE \u0026lt;maximum_size\u0026gt;; -- Example: 512 MB increment up to 10 GB maximum ALTER DATABASE DATAFILE \u0026#39;/u01/oradata/ORCL/users01.dbf\u0026#39; AUTOEXTEND ON NEXT 512M MAXSIZE 10240M; Disable autoextend ALTER DATABASE DATAFILE \u0026#39;/u01/oradata/ORCL/users01.dbf\u0026#39; AUTOEXTEND OFF; Autoextend Parameters Parameter Description NEXT Size of each automatic extension increment MAXSIZE Maximum size the file can reach UNLIMITED Allows growth up to the file system limit (use with caution!) Adding New Datafiles When it is not possible (or desirable) to increase existing files, the best alternative is to add a new datafile to the tablespace.\nAdd a datafile to an existing tablespace -- Syntax ALTER TABLESPACE \u0026lt;tablespace_name\u0026gt; ADD DATAFILE \u0026#39;\u0026lt;new_file_path\u0026gt;\u0026#39; SIZE \u0026lt;size\u0026gt; AUTOEXTEND ON NEXT \u0026lt;increment\u0026gt; MAXSIZE \u0026lt;maximum\u0026gt;; -- Example: add a new 1 GB datafile to the USERS tablespace ALTER TABLESPACE USERS ADD DATAFILE \u0026#39;/u01/oradata/ORCL/users02.dbf\u0026#39; SIZE 1024M AUTOEXTEND ON NEXT 256M MAXSIZE 4096M; Add a tempfile to a temporary tablespace ALTER TABLESPACE TEMP ADD TEMPFILE \u0026#39;/u01/oradata/ORCL/temp02.dbf\u0026#39; SIZE 512M AUTOEXTEND ON NEXT 128M MAXSIZE 2048M; Best Practices Monitoring Set up alerts for tablespaces that exceed 80% usage. Use the dba_tablespace_usage_metrics view for a consolidated overview on 11g+ databases: SELECT tablespace_name, ROUND(used_space * 8192 / 1024 / 1024, 2) AS used_mb, ROUND(tablespace_size * 8192 / 1024 / 1024, 2) AS total_mb, ROUND(used_percent, 2) AS pct_used FROM dba_tablespace_usage_metrics ORDER BY used_percent DESC; Datafile Organization Distribute datafiles across different disks to improve I/O performance. Avoid using MAXSIZE UNLIMITED; always define a safe limit. Prefer multiple smaller datafiles over a single large file. Name files consistently: \u0026lt;tablespace\u0026gt;NN.dbf (e.g., users01.dbf, users02.dbf). Common Errors and Solutions Oracle Error Likely Cause Solution ORA-01653 Tablespace out of free space Increase datafile or add a new one ORA-01652 TEMP tablespace out of space Increase tempfile ORA-19502 Error writing to datafile Check disk space on the OS ORA-01144 File size exceeds the limit Use multiple smaller datafiles Required permissions: To execute the commands in this tutorial, the user must have the DBA privilege or, at minimum, ALTER TABLESPACE and access to the views DBA_DATA_FILES, DBA_FREE_SPACE, and DBA_TABLESPACES.\n","permalink":"https://www.leocardozo.com/en/tutoriais/ajustar-tablespaces-oracle/","summary":"\u003ch1 id=\"tutorial-tablespace-management-in-oracle-database\"\u003eTutorial: Tablespace Management in Oracle Database\u003c/h1\u003e\n\u003chr\u003e\n\u003ch2 id=\"what-is-a-tablespace\"\u003eWhat is a Tablespace?\u003c/h2\u003e\n\u003cp\u003eA \u003cstrong\u003etablespace\u003c/strong\u003e is the logical storage unit in Oracle Database. It logically groups data segments (tables, indexes, etc.) and is physically composed of one or more \u003cstrong\u003edatafiles\u003c/strong\u003e on the operating system.\u003c/p\u003e\n\u003cp\u003eEvery Oracle database has at least the following default tablespaces:\u003c/p\u003e\n\u003ctable\u003e\n  \u003cthead\u003e\n      \u003ctr\u003e\n          \u003cth\u003eTablespace\u003c/th\u003e\n          \u003cth\u003eDescription\u003c/th\u003e\n      \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n      \u003ctr\u003e\n          \u003ctd\u003e\u003ccode\u003eSYSTEM\u003c/code\u003e\u003c/td\u003e\n          \u003ctd\u003eData dictionary and Oracle internal objects\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003e\u003ccode\u003eSYSAUX\u003c/code\u003e\u003c/td\u003e\n          \u003ctd\u003eAuxiliary components (AWR, statspack, etc.)\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003e\u003ccode\u003eTEMP\u003c/code\u003e\u003c/td\u003e\n          \u003ctd\u003eTemporary operations (sorts, joins, group by)\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003e\u003ccode\u003eUNDOTBS1\u003c/code\u003e\u003c/td\u003e\n          \u003ctd\u003eUndo data storage (rollback)\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n          \u003ctd\u003e\u003ccode\u003eUSERS\u003c/code\u003e\u003c/td\u003e\n          \u003ctd\u003eDefault tablespace for user objects\u003c/td\u003e\n      \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003chr\u003e\n\u003ch2 id=\"listing-tablespaces\"\u003eListing Tablespaces\u003c/h2\u003e\n\u003ch3 id=\"list-all-tablespaces-in-the-database\"\u003eList all tablespaces in the database\u003c/h3\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"\u003e\u003ccode class=\"language-sql\" data-lang=\"sql\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eSELECT\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    tablespace_name,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    status,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    contents,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    logging,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    extent_management,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    segment_space_management\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eFROM\u003c/span\u003e dba_tablespaces\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eORDER\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003eBY\u003c/span\u003e tablespace_name;\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch3 id=\"list-datafiles-associated-with-each-tablespace\"\u003eList datafiles associated with each tablespace\u003c/h3\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"\u003e\u003ccode class=\"language-sql\" data-lang=\"sql\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eSELECT\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    tablespace_name,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    file_name,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    bytes \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e        \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e size_mb,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    autoextensible,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    maxbytes \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e     \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e max_size_mb\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eFROM\u003c/span\u003e dba_data_files\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eORDER\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003eBY\u003c/span\u003e tablespace_name, file_name;\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch3 id=\"list-tempfiles-temporary-tablespaces\"\u003eList tempfiles (temporary tablespaces)\u003c/h3\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"\u003e\u003ccode class=\"language-sql\" data-lang=\"sql\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eSELECT\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    tablespace_name,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    file_name,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    bytes \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e    \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e size_mb,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    autoextensible\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eFROM\u003c/span\u003e dba_temp_files\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eORDER\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003eBY\u003c/span\u003e tablespace_name;\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003chr\u003e\n\u003ch2 id=\"checking-usage-and-free-space\"\u003eChecking Usage and Free Space\u003c/h2\u003e\n\u003ch3 id=\"view-free-space-per-tablespace\"\u003eView free space per tablespace\u003c/h3\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"\u003e\u003ccode class=\"language-sql\" data-lang=\"sql\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eSELECT\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    df.tablespace_name                                        \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e tablespace,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    ROUND(df.total_mb, \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e)                                     \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e total_mb,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    ROUND(fs.free_mb, \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e)                                      \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e free_mb,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    ROUND(df.total_mb \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003e fs.free_mb, \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e)                        \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e used_mb,\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    ROUND((df.total_mb \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003e fs.free_mb) \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e df.total_mb \u003cspan style=\"color:#f92672\"\u003e*\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e100\u003c/span\u003e, \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e) \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e pct_used\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eFROM\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    (\u003cspan style=\"color:#66d9ef\"\u003eSELECT\u003c/span\u003e tablespace_name, \u003cspan style=\"color:#66d9ef\"\u003eSUM\u003c/span\u003e(bytes) \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e total_mb\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     \u003cspan style=\"color:#66d9ef\"\u003eFROM\u003c/span\u003e dba_data_files\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     \u003cspan style=\"color:#66d9ef\"\u003eGROUP\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003eBY\u003c/span\u003e tablespace_name) df\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eJOIN\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    (\u003cspan style=\"color:#66d9ef\"\u003eSELECT\u003c/span\u003e tablespace_name, \u003cspan style=\"color:#66d9ef\"\u003eSUM\u003c/span\u003e(bytes) \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e/\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e1024\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003eAS\u003c/span\u003e free_mb\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     \u003cspan style=\"color:#66d9ef\"\u003eFROM\u003c/span\u003e dba_free_space\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     \u003cspan style=\"color:#66d9ef\"\u003eGROUP\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003eBY\u003c/span\u003e tablespace_name) fs\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eON\u003c/span\u003e df.tablespace_name \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e fs.tablespace_name\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eORDER\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003eBY\u003c/span\u003e pct_used \u003cspan style=\"color:#66d9ef\"\u003eDESC\u003c/span\u003e;\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cblockquote\u003e\n\u003cp\u003e\u003cstrong\u003eWarning:\u003c/strong\u003e Tablespaces exceeding \u003cstrong\u003e85% usage\u003c/strong\u003e require immediate attention to avoid errors such as \u003ccode\u003eORA-01653: unable to extend table\u003c/code\u003e.\u003c/p\u003e","title":"Adjusting Oracle Table Spaces"}]