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) -> CreateDatabaseBuilder

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>) -> CreateDatabaseBuilder

Set the location for the database.

Source

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

Set the managed location for the database.

Source

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

Set whether this is an OR REPLACE operation.

Source

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

Set whether this is a transient database.

Source

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

Set whether to use IF NOT EXISTS.

Source

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

Set the clone clause for the database.

Source

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

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>, ) -> CreateDatabaseBuilder

Set the maximum data extension time in days.

Source

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

Set the external volume for the database.

Source

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

Set the catalog for the database.

Source

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

Set whether to replace invalid characters.

Source

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

Set the default DDL collation.

Source

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

Set the storage serialization policy.

Source

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

Set the comment for the database.

Source

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

Set the default character set for the database.

Source

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

Set the default collation for the database.

Source

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

Set the catalog sync for the database.

Source

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

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>, ) -> CreateDatabaseBuilder

Set the catalog sync namespace flatten delimiter for the database.

Source

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

Set the tags for the database.

Source

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

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 (const: unstable) · 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<(), Error>

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

impl Eq for CreateDatabaseBuilder

Source§

impl Hash for CreateDatabaseBuilder

Source§

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

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 (const: unstable) · 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 StructuralPartialEq for CreateDatabaseBuilder

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<CreateDatabaseBuilder, <CreateDatabaseBuilder as TryFrom<Statement>>::Error>

Performs the conversion.
Source§

impl Visit for CreateDatabaseBuilder

Source§

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

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

impl VisitMut for CreateDatabaseBuilder

Source§

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

Mutably visit this node with the provided VisitorMut. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<Source> AccessAs for Source

Source§

fn ref_as<T>(&self) -> <Source as IGuardRef<T>>::Guard<'_>
where Source: IGuardRef<T>, T: ?Sized,

Provides immutable access to a type as if it were its ABI-unstable equivalent.
Source§

fn mut_as<T>(&mut self) -> <Source as IGuardMut<T>>::GuardMut<'_>
where Source: IGuardMut<T>, T: ?Sized,

Provides mutable access to a type as if it were its ABI-unstable equivalent.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynEq for T
where T: Eq + Any,

Source§

fn dyn_eq(&self, other: &(dyn Any + 'static)) -> bool

Source§

impl<T> DynHash for T
where T: Hash + Any,

Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, As> IGuardMut<As> for T
where T: Into<As>, As: Into<T>,

Source§

type GuardMut<'a> = MutAs<'a, T, As> where T: 'a

The type of the guard which will clean up the temporary after applying its changes to the original.
Source§

fn guard_mut_inner(&mut self) -> <T as IGuardMut<As>>::GuardMut<'_>

Construct the temporary and guard it through a mutable reference.
Source§

impl<T, As> IGuardRef<As> for T
where T: Into<As>, As: Into<T>,

Source§

type Guard<'a> = RefAs<'a, T, As> where T: 'a

The type of the guard which will clean up the temporary.
Source§

fn guard_ref_inner(&self) -> <T as IGuardRef<As>>::Guard<'_>

Construct the temporary and guard it through an immutable reference.
Source§

impl<T> Includes<End> for T

Source§

type Output = End

The result
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> Ungil for T
where T: Send,

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more