sqlparser/statements.cpp
// CREATE SCHEMA in SQL Server, MySQL, Redshift
CREATE SCHEMA in SQL Server, MySQL, Redshift
CREATE SCHEMA in SQL Server MySQL Redshift
bool SqlParser::ParseCreateSchema(Token *create, Token *schema)
{
	if(create == NULL || schema == NULL)
		return false;
	STATS_DECL
	STATS_SET_DESC(SQL_STMT_CREATE_SCHEMA_DESC)
	Token *if_ = GetNext("IF", L"IF", 2);
	Token *not_ = GetNext(if_, "NOT", L"NOT", 3);
	Token *exists = GetNext(not_, "EXISTS", L"EXISTS", 6);
	Token *name = GetNextIdentToken(SQL_IDENT_OBJECT);
	if(name == NULL)
	{
	    STMS_STATS_V("CREATE SCHEMA", create);
		return false;
	}
	while(true)
	{
		Token *default_ = GetNext("DEFAULT", L"DEFAULT", 7);
		Token *next = GetNext();
		if(next == NULL)
			break;
		if(next->Compare("CHARACTER", L"CHARACTER", 9) == true)
		{
			Token *set = GetNext("SET", L"SET", 3);
			 (void) GetNext(set, '=', L'=');
			Token *name = GetNext(set);
			if(_target == SQL_ORACLE && name != NULL)
				Comment(Nvl(default_, next), name);
		}
		else
		if(next->Compare("COLLATE", L"COLLATE", 7) == true)
		{
			 (void) GetNext('=', L'=');
			Token *name = GetNext();
			if(_target == SQL_ORACLE && name != NULL)
				Comment(Nvl(default_, next), name);
		}
		else
		if(TOKEN_CMP(next, "AUTHORIZATION"))
		{
			 (void) GetNext();
		}
		else
		{
			PushBack(next);
			break;
		}
	}
	if(_target == SQL_ORACLE)
	{
		Token::Change(schema, "USER", L"USER", 4);
		Append(name, " IDENTIFIED BY ", L" IDENTIFIED BY ", 15, create);
		AppendCopy(name, name);
		Token::Remove(if_, exists);
	}
	SqlServerDelimiter();
    STMS_STATS_V("CREATE SCHEMA", create);
	return true;
}
bool SqlParser :: ParseCreateSchema ( Token * create , Token * schema ) { if ( create == NULL || schema == NULL ) return false ; STATS_DECL STATS_SET_DESC ( SQL_STMT_CREATE_SCHEMA_DESC ) Token * if_ = GetNext ( " " , L" " , 2 ) ; Token * not_ = GetNext ( if_ , " " , L" " , 3 ) ; Token * exists = GetNext ( not_ , " " , L" " , 6 ) ; Token * name = GetNextIdentToken ( SQL_IDENT_OBJECT ) ; if ( name == NULL ) { STMS_STATS_V ( " " , create ) ; return false ; } while ( true ) { Token * default_ = GetNext ( " " , L" " , 7 ) ; Token * next = GetNext ( ) ; if ( next == NULL ) break ; if ( next -> Compare ( " " , L" " , 9 ) == true ) { Token * set = GetNext ( " " , L" " , 3 ) ; ( void ) GetNext ( set , ' ' , L' ' ) ; Token * name = GetNext ( set ) ; if ( _target == SQL_ORACLE && name != NULL ) Comment ( Nvl ( default_ , next ) , name ) ; } else if ( next -> Compare ( " " , L" " , 7 ) == true ) { ( void ) GetNext ( ' ' , L' ' ) ; Token * name = GetNext ( ) ; if ( _target == SQL_ORACLE && name != NULL ) Comment ( Nvl ( default_ , next ) , name ) ; } else if ( TOKEN_CMP ( next , " " ) ) { ( void ) GetNext ( ) ; } else { PushBack ( next ) ; break ; } } if ( _target == SQL_ORACLE ) { Token :: Change ( schema , " " , L" " , 4 ) ; Append ( name , " " , L" " , 15 , create ) ; AppendCopy ( name , name ) ; Token :: Remove ( if_ , exists ) ; } SqlServerDelimiter ( ) ; STMS_STATS_V ( " " , create ) ; return true ; }
CREATE SCHEMA in SQL Server, MySQL, Redshift
CREATE SCHEMA in SQL Server MySQL Redshift
// IF NOT EXISTS in MySQL // Database name in MySQL // Options // In MySQL options can start with optional DEFAULT keyword // [DEFAULT] CHARACTER SET [=] name in MySQL // Optional =  /*Token *equal */ // Default character set name // [DEFAULT] COLLATE [=] name in MySQL // Optional =  /*Token *equal */ // Default collate name // AUTHORIZATION name in DB2 // Authorization name /*Token *name */ // CREATE USER in Oracle // Add default password // Add statement delimiter if not set and handle GO when source is SQL Server, Sybase ASE