Class: SQLStatement::SelectCreate

Inherits:
Select show all
Defined in:
lib/sql/statement.rb

Overview

Creates a statement of the form

CREATE [TEMPORARY] TABLE targettable SELECT ... FROM ... WHERE ...

Instance Attribute Summary collapse

Attributes inherited from Select

#conditions, #distinct, #fields, #groupby, #orderby, #tables

Instance Method Summary collapse

Methods inherited from Select

#<<, #add_fields, #add_tables, #allfields, newlists, #placeheld, #to_sqlpart

Constructor Details

#initialize(targettable, temporary = false) ⇒ SelectCreate

Returns a new instance of SelectCreate.



438
439
440
441
442
# File 'lib/sql/statement.rb', line 438

def initialize(targettable,temporary=false)
   super()
   @targettable=targettable
   @temporary=temporary
end

Instance Attribute Details

#targettableObject

The name of the table to create.



431
432
433
# File 'lib/sql/statement.rb', line 431

def targettable
  @targettable
end

#temporaryObject

Indicates whether a temporary table (which automatically deletes itself when the connection to the database closes) should be created. This may not be supported by all databases.



436
437
438
# File 'lib/sql/statement.rb', line 436

def temporary
  @temporary
end

Instance Method Details

#to_sObject



444
445
446
# File 'lib/sql/statement.rb', line 444

def to_s
   "CREATE #{ @temporary ? 'TEMPORARY':''} TABLE #{@targettable.to_sqlpart} #{super}"
end