The emailaddr extension in PostgreSQL provides a specialized data type for storing and validating email addresses. This extension ensures proper email formatting and allows efficient querying. Your Nile database arrives withDocumentation Index
Fetch the complete documentation index at: https://thenile.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
emailaddr extension already installed and enabled.
Creating and Populating contacts Table
Before using emailaddr, let’s create a sample table to store email addresses of key contacts:
Querying Email Addresses
SinceEMAILADDR is a specialized type, queries can be performed as with standard text columns:
Validating Email Format
Theemailaddr type ensures that only valid email addresses are stored. For example, the following insertion will fail:
'not_an_email' is not a properly formatted email address.
Limitations
EMAILADDRensures correct email formatting but does not verify if the email exists.- Cannot store internationalized email addresses using Unicode.
Removing an Index
If you need to remove the index:Conclusion
Theemailaddr extension in PostgreSQL simplifies email validation and storage while ensuring efficient indexing for lookup queries.
For more details, refer to the official PostgreSQL documentation or community resources.