Skip to main content

CreateDatabaseBuilder

Struct CreateDatabaseBuilder 

Source
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: ObjectName

The database name to create.

§if_not_exists: bool

Whether IF NOT EXISTS was specified.

§location: Option<String>

Optional storage location for the database.

§managed_location: Option<String>

Optional managed storage location.

§or_replace: bool

Whether OR REPLACE was specified.

§transient: bool

Whether 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>§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.

§with_tags: Option<Vec<Tag>>

Optional tags attached to the database.

§with_contacts: Option<Vec<ContactEntry>>

Optional contact entries associated with the database.

Implementations§

Source§

impl CreateDatabaseBuilder

Source

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.
Source

pub fn location(self, location: Option<String>) -> Self

Set the location for the database.

Source

pub fn managed_location(self, managed_location: Option<String>) -> Self

Set the managed location for the database.

Source

pub fn or_replace(self, or_replace: bool) -> Self

Set whether this is an OR REPLACE operation.

Source

pub fn transient(self, transient: bool) -> Self

Set whether this is a transient database.

Source

pub fn if_not_exists(self, if_not_exists: bool) -> Self

Set whether to use IF NOT EXISTS.

Source

pub fn clone_clause(self, clone: Option<ObjectName>) -> Self

Set the clone clause for the database.

Source

pub fn data_retention_time_in_days( self, data_retention_time_in_days: Option<u64>, ) -> Self

Set the data retention time in days.

Source

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.

Source

pub fn external_volume(self, external_volume: Option<String>) -> Self

Set the external volume for the database.

Source

pub fn catalog(self, catalog: Option<String>) -> Self

Set the catalog for the database.

Source

pub fn replace_invalid_characters( self, replace_invalid_characters: Option<bool>, ) -> Self

Set whether to replace invalid characters.

Source

pub fn default_ddl_collation( self, default_ddl_collation: Option<String>, ) -> Self

Set the default DDL collation.

Source

pub fn storage_serialization_policy( self, storage_serialization_policy: Option<StorageSerializationPolicy>, ) -> Self

Set the storage serialization policy.

Source

pub fn comment(self, comment: Option<String>) -> Self

Set the comment for the database.

Source

pub fn default_charset(self, default_charset: Option<String>) -> Self

Set the default character set for the database.

Source

pub fn default_collation(self, default_collation: Option<String>) -> Self

Set the default collation for the database.

Source

pub fn catalog_sync(self, catalog_sync: Option<String>) -> Self

Set the catalog sync for the database.

Source

pub fn catalog_sync_namespace_mode( self, catalog_sync_namespace_mode: Option<CatalogSyncNamespaceMode>, ) -> Self

Set the catalog sync namespace mode for the database.

Source

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.

Source

pub fn with_tags(self, with_tags: Option<Vec<Tag>>) -> Self

Set the tags for the database.

Source

pub fn with_contacts(self, with_contacts: Option<Vec<ContactEntry>>) -> Self

Set the contacts for the database.

Source

pub fn build(self) -> Statement

Build the CREATE DATABASE statement.

Trait Implementations§

Source§

impl Clone for CreateDatabaseBuilder

Source§

fn clone(&self) -> CreateDatabaseBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CreateDatabaseBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for CreateDatabaseBuilder

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CreateDatabaseBuilder

Source§

fn eq(&self, other: &CreateDatabaseBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Statement> for CreateDatabaseBuilder

Source§

type Error = ParserError

The type returned in the event of a conversion error.
Source§

fn try_from(stmt: Statement) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Visit for CreateDatabaseBuilder

Source§

fn visit<V: Visitor>(&self, visitor: &mut V) -> ControlFlow<V::Break>

Visit this node with the provided Visitor. Read more
Source§

impl VisitMut for CreateDatabaseBuilder

Source§

fn visit<V: VisitorMut>(&mut self, visitor: &mut V) -> ControlFlow<V::Break>

Mutably visit this node with the provided VisitorMut. Read more
Source§

impl Eq for CreateDatabaseBuilder

Source§

impl StructuralPartialEq for CreateDatabaseBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.