Pii detection in SQL*Plus is not about guesswork. It is about knowing exactly how your data is shaped, where it lives, and how it moves. Running raw queries without safeguards risks exposing sensitive names, addresses, emails, phone numbers, and identification numbers. Once exposed, these fields can create compliance failures and security breaches.
To detect PII in SQL*Plus, start with structured scanning. Apply REGEXP_LIKE to search for common PII formats directly in your query output. For example:
SELECT customer_id, email
FROM customers
WHERE REGEXP_LIKE(email, '^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$', 'i');
Pattern-based detection should be paired with column-level audits. Query ALL_TAB_COLUMNS to inspect field names and data types that frequently store PII, such as VARCHAR2 with names containing “email”, “phone”, “dob”, “ssn”, or “address.” This approach makes PII detection repeatable and scalable.
Export processes in SQL*Plus need the same discipline. Use SPOOL only when necessary. If spooling query results containing PII, ensure the output file is encrypted and stored securely. This prevents leaks at the layer between query execution and downstream processing.