@@ -10465,6 +10465,63 @@ impl fmt::Display for CreateUser {
1046510465 }
1046610466}
1046710467
10468+ /// Specifies how to create a new table based on an existing table's schema.
10469+ ///
10470+ /// Not parenthesized:
10471+ /// '''sql
10472+ /// CREATE TABLE new LIKE old ...
10473+ /// '''
10474+ /// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-table#label-create-table-like)
10475+ /// [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_like)
10476+ ///
10477+ /// Parenthesized:
10478+ /// '''sql
10479+ /// CREATE TABLE new (LIKE old ...)
10480+ /// '''
10481+ /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html)
10482+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10483+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10484+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10485+ pub enum CreateTableLikeKind {
10486+ Parenthesized ( CreateTableLike ) ,
10487+ NotParenthesized ( CreateTableLike ) ,
10488+ }
10489+
10490+ #[ derive( Debug , Copy , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10491+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10492+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10493+ pub enum CreateTableLikeDefaults {
10494+ Including ,
10495+ Excluding ,
10496+ }
10497+
10498+ impl fmt:: Display for CreateTableLikeDefaults {
10499+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10500+ match self {
10501+ CreateTableLikeDefaults :: Including => write ! ( f, "INCLUDING DEFAULTS" ) ,
10502+ CreateTableLikeDefaults :: Excluding => write ! ( f, "EXCLUDING DEFAULTS" ) ,
10503+ }
10504+ }
10505+ }
10506+
10507+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10508+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10509+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10510+ pub struct CreateTableLike {
10511+ pub name : ObjectName ,
10512+ pub defaults : Option < CreateTableLikeDefaults > ,
10513+ }
10514+
10515+ impl fmt:: Display for CreateTableLike {
10516+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10517+ write ! ( f, "LIKE {}" , self . name) ?;
10518+ if let Some ( defaults) = & self . defaults {
10519+ write ! ( f, " {defaults}" ) ?;
10520+ }
10521+ Ok ( ( ) )
10522+ }
10523+ }
10524+
1046810525#[ cfg( test) ]
1046910526mod tests {
1047010527 use crate :: tokenizer:: Location ;
0 commit comments