pub struct CreateDatabaseBuilder {Show 22 fields
pub db_name: ObjectName,
pub if_not_exists: bool,
pub location: Option<String>,
pub managed_location: Option<String>,
pub or_replace: bool,
pub transient: bool,
pub clone: Option<ObjectName>,
pub data_retention_time_in_days: Option<u64>,
pub max_data_extension_time_in_days: Option<u64>,
pub external_volume: Option<String>,
pub catalog: Option<String>,
pub replace_invalid_characters: Option<bool>,
pub default_ddl_collation: Option<String>,
pub storage_serialization_policy: Option<StorageSerializationPolicy>,
pub comment: Option<String>,
pub default_charset: Option<String>,
pub default_collation: Option<String>,
pub catalog_sync: Option<String>,
pub catalog_sync_namespace_mode: Option<CatalogSyncNamespaceMode>,
pub catalog_sync_namespace_flatten_delimiter: Option<String>,
pub with_tags: Option<Vec<Tag>>,
pub with_contacts: Option<Vec<ContactEntry>>,
}Expand description
Builder for create database statement variant (1).
This structure helps building and accessing a create database with more ease, without needing to:
- Match the enum itself a lot of times; or
- Moving a lot of variables around the code.
§Example
use sqlparser::ast::helpers::stmt_create_database::CreateDatabaseBuilder;
use sqlparser::ast::{ColumnDef, Ident, ObjectName};
let builder = CreateDatabaseBuilder::new(ObjectName::from(vec![Ident::new("database_name")]))
.if_not_exists(true);
// You can access internal elements with ease
assert!(builder.if_not_exists);
// Convert to a statement
assert_eq!(
builder.build().to_string(),
"CREATE DATABASE IF NOT EXISTS database_name"
)Fields§
§db_name: ObjectNameThe database name to create.
if_not_exists: boolWhether IF NOT EXISTS was specified.
location: Option<String>Optional storage location for the database.
managed_location: Option<String>Optional managed storage location.
or_replace: boolWhether OR REPLACE was specified.
transient: boolWhether the database is TRANSIENT.
clone: Option<ObjectName>Optional CLONE source object name.
data_retention_time_in_days: Option<u64>Optional data retention time in days.
max_data_extension_time_in_days: Option<u64>Optional max data extension time in days.
external_volume: Option<String>Optional external volume identifier.
catalog: Option<String>Optional catalog name.
replace_invalid_characters: Option<bool>Whether to replace invalid characters.
default_ddl_collation: Option<String>Optional default DDL collation.
storage_serialization_policy: Option<StorageSerializationPolicy>Optional storage serialization policy.
comment: Option<String>Optional comment attached to the database.
default_charset: Option<String>Optional default character set (MySQL).
https://dev.mysql.com/doc/refman/8.4/en/create-database.html
default_collation: Option<String>Optional default collation (MySQL).
https://dev.mysql.com/doc/refman/8.4/en/create-database.html
catalog_sync: Option<String>Optional catalog sync configuration.
catalog_sync_namespace_mode: Option<CatalogSyncNamespaceMode>Optional catalog sync namespace mode.
catalog_sync_namespace_flatten_delimiter: Option<String>Optional namespace flatten delimiter for catalog sync.
Optional tags attached to the database.
with_contacts: Option<Vec<ContactEntry>>Optional contact entries associated with the database.
Implementations§
Source§impl CreateDatabaseBuilder
impl CreateDatabaseBuilder
Sourcepub fn new(name: ObjectName) -> Self
pub fn new(name: ObjectName) -> Self
Create a new CreateDatabaseBuilder with the given database name.
§Arguments
name- The name of the database to be created.
Sourcepub fn managed_location(self, managed_location: Option<String>) -> Self
pub fn managed_location(self, managed_location: Option<String>) -> Self
Set the managed location for the database.
Sourcepub fn or_replace(self, or_replace: bool) -> Self
pub fn or_replace(self, or_replace: bool) -> Self
Set whether this is an OR REPLACE operation.
Sourcepub fn if_not_exists(self, if_not_exists: bool) -> Self
pub fn if_not_exists(self, if_not_exists: bool) -> Self
Set whether to use IF NOT EXISTS.
Sourcepub fn clone_clause(self, clone: Option<ObjectName>) -> Self
pub fn clone_clause(self, clone: Option<ObjectName>) -> Self
Set the clone clause for the database.
Sourcepub fn data_retention_time_in_days(
self,
data_retention_time_in_days: Option<u64>,
) -> Self
pub fn data_retention_time_in_days( self, data_retention_time_in_days: Option<u64>, ) -> Self
Set the data retention time in days.
Sourcepub fn max_data_extension_time_in_days(
self,
max_data_extension_time_in_days: Option<u64>,
) -> Self
pub fn max_data_extension_time_in_days( self, max_data_extension_time_in_days: Option<u64>, ) -> Self
Set the maximum data extension time in days.
Sourcepub fn external_volume(self, external_volume: Option<String>) -> Self
pub fn external_volume(self, external_volume: Option<String>) -> Self
Set the external volume for the database.
Sourcepub fn replace_invalid_characters(
self,
replace_invalid_characters: Option<bool>,
) -> Self
pub fn replace_invalid_characters( self, replace_invalid_characters: Option<bool>, ) -> Self
Set whether to replace invalid characters.
Sourcepub fn default_ddl_collation(
self,
default_ddl_collation: Option<String>,
) -> Self
pub fn default_ddl_collation( self, default_ddl_collation: Option<String>, ) -> Self
Set the default DDL collation.
Sourcepub fn storage_serialization_policy(
self,
storage_serialization_policy: Option<StorageSerializationPolicy>,
) -> Self
pub fn storage_serialization_policy( self, storage_serialization_policy: Option<StorageSerializationPolicy>, ) -> Self
Set the storage serialization policy.
Sourcepub fn default_charset(self, default_charset: Option<String>) -> Self
pub fn default_charset(self, default_charset: Option<String>) -> Self
Set the default character set for the database.
Sourcepub fn default_collation(self, default_collation: Option<String>) -> Self
pub fn default_collation(self, default_collation: Option<String>) -> Self
Set the default collation for the database.
Sourcepub fn catalog_sync(self, catalog_sync: Option<String>) -> Self
pub fn catalog_sync(self, catalog_sync: Option<String>) -> Self
Set the catalog sync for the database.
Sourcepub fn catalog_sync_namespace_mode(
self,
catalog_sync_namespace_mode: Option<CatalogSyncNamespaceMode>,
) -> Self
pub fn catalog_sync_namespace_mode( self, catalog_sync_namespace_mode: Option<CatalogSyncNamespaceMode>, ) -> Self
Set the catalog sync namespace mode for the database.
Sourcepub fn catalog_sync_namespace_flatten_delimiter(
self,
catalog_sync_namespace_flatten_delimiter: Option<String>,
) -> Self
pub fn catalog_sync_namespace_flatten_delimiter( self, catalog_sync_namespace_flatten_delimiter: Option<String>, ) -> Self
Set the catalog sync namespace flatten delimiter for the database.
Set the tags for the database.
Sourcepub fn with_contacts(self, with_contacts: Option<Vec<ContactEntry>>) -> Self
pub fn with_contacts(self, with_contacts: Option<Vec<ContactEntry>>) -> Self
Set the contacts for the database.
Trait Implementations§
Source§impl Clone for CreateDatabaseBuilder
impl Clone for CreateDatabaseBuilder
Source§fn clone(&self) -> CreateDatabaseBuilder
fn clone(&self) -> CreateDatabaseBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CreateDatabaseBuilder
impl Debug for CreateDatabaseBuilder
Source§impl Hash for CreateDatabaseBuilder
impl Hash for CreateDatabaseBuilder
Source§impl PartialEq for CreateDatabaseBuilder
impl PartialEq for CreateDatabaseBuilder
Source§impl TryFrom<Statement> for CreateDatabaseBuilder
impl TryFrom<Statement> for CreateDatabaseBuilder
Source§impl Visit for CreateDatabaseBuilder
impl Visit for CreateDatabaseBuilder
Source§impl VisitMut for CreateDatabaseBuilder
impl VisitMut for CreateDatabaseBuilder
Source§fn visit<V: VisitorMut>(&mut self, visitor: &mut V) -> ControlFlow<V::Break>
fn visit<V: VisitorMut>(&mut self, visitor: &mut V) -> ControlFlow<V::Break>
VisitorMut. Read more