Returns SQL to define the table.
1822
def ddl(self, dialect=None, creates=True, drops=True):
        
        dialect = self._dialect(dialect)
        creator = CreateTable(self.table).compile(mock_engines[dialect])
        creator = "\n".join(l for l in str(creator).splitlines() if l.strip()) # remove empty lines
        comments = "\n\n".join(self._comment_wrapper.fill("in %s: %s" %
                                                        (col, self.comments[col]))
                                                        for col in self.comments)
        result = []
        if drops:
            result.append(self._dropper(dialect) + ';')
        if creates:
            result.append("%s;\n%s" % (creator, comments))
        for child in self.children.values():
            result.append(child.ddl(dialect=dialect, creates=creates,
                          drops=drops))
        return '\n\n'.join(result)
547141
def create_table_sql(cls, db):
        '''
        
        '''
        parts = ['CREATE TABLE IF NOT EXISTS `%s`.`%s` AS `%s`.`%s`' % (db.db_name, cls.table_name(), db.db_name,
                                                                        cls.engine.main_model.table_name())]
        engine_str = cls.engine.create_table_sql(db)
        parts.append(engine_str)
        return ' '.join(parts)
712934
public function get_table_definition($table) {
		$statement = $this->get_statement('DESC ' . $this->quote_identifier($table), []);
		$statement->execute();
		$result = $statement->fetch_assoc();
		return $result;
	}
594778
def tables(self):
        
        if self.schema:
            return self.tables_in_schema(self.schema)
        else:
            tables = []
            for schema in self.schemas:
                tables = tables + [
                    schema + "." + t for t in self.tables_in_schema(schema)
                ]
            return tables
305519
public function getSql()
    {
        $where = (count($this->conditions) === 0)
            ? ''
            : 'WHERE ' . implode(' and ', $this->conditions);
        $sql = "SELECT $this->select FROM $this->table $where $this->order $this->limit $this->offset";
        return $sql;
    }
1262189
def to_sql(self):
        
        return self._sql_query_skeleton.format(
            prefix=self.prefix, select=self.select_block,
            relation=self.from_block, conditions=self.where_block)
1029760
function getTableDefinition(tableDefinitions, tableName) {
    Validate.isObject(tableDefinitions);
    Validate.notNull(tableDefinitions);
    Validate.isString(tableName);
    Validate.notNullOrEmpty(tableName);

    return tableDefinitions[tableName.toLowerCase()];
}
1185511
public Set<String> getTable(String sql) {
		Set<String> tableSet = new HashSet<String>();
		
		try {
			Statement statement = parserManager.parse(new StringReader(sql));
			
			if (statement instanceof Select) {
				tableSet = new SelectParser().parse((Select)statement);
			} else if (statement instanceof Delete) {
				tableSet = new DeleteParser().parse((Delete)statement);
			} else if (statement instanceof Insert) {
				tableSet = new InsertParser().parse((Insert)statement);
			} else if (statement instanceof Update) {
				tableSet = new UpdateParser().parse((Update)statement);
			} else if (statement instanceof CreateTable) {
				tableSet = new CreateTableParser().parse((CreateTable)statement);
			} else if (statement instanceof CreateView) {
				tableSet = new CreateViewParser().parse((CreateView)statement);
			} else if (statement instanceof Alter) {
				tableSet = new AlterParser().parse((Alter)statement);
			} else if (statement instanceof Drop) {
				tableSet = new DropParser().parse((Drop)statement);
			}
		} catch (Exception e) {
			logger.debug(String.format("SQL Parse Exception: exception=%s, sql=%s", e.getMessage(), sql));
		} catch (Error e) {
			logger.debug(String.format("SQL Parse Exception: exception=%s, sql=%s", e.getMessage(), sql));
		}
		
		Set<String> resultSet = new HashSet<String>();
		for (String tableName : tableSet) {
			if (StringUtils.isNotEmpty(tableName)) {
				if (tableName.startsWith("`")) {
					tableName = tableName.substring(1);
				}
				if (tableName.endsWith("`")) {
					tableName = tableName.substring(0, tableName.length() - 1);
				}
				resultSet.add(tableName.toUpperCase());
			}
		}
		
		return resultSet;
	}
46862
private boolean getTableDefinition(Connection tbcon) throws SQLException {
        boolean defExists = false;
        boolean smallExists = false;
        boolean mediumExists = false;
        boolean largeExists = false;

        //informix size calculation doesn't
        //work. i.e rs1.getInt("COLUMN_SIZE") doesn't work
        //if (usingInformix)
        //    return false;

        DatabaseMetaData dmd = tbcon.getMetaData();
        String tbName = tableName;
        String qualifierName = null;

        if (usingAS400DB2 || usingDB2Connect) {
            tbName = TABLE_NAME.toUpperCase();
            if (collectionName != null)
                qualifierName = collectionName;
        } else if (usingDB2 || usingDerby || usingOracle) { // cmd 162172
            tbName = tbName.toUpperCase();
            if (dbid != null) {
                qualifierName = dbid.toUpperCase(); // cmd PQ81615
            }

            if (_smc.isUsingCustomSchemaName()) { //PM27191
                if (usingDB2) {
                    java.sql.Statement s = null;
                    ResultSet rs1 = null;
                    s = tbcon.createStatement();
                    s.execute("VALUES (CURRENT SCHEMA)");
                    rs1 = s.getResultSet();
                    while (rs1.next()) {
                        qualifierNameWhenCustomSchemaIsSet = rs1.getString("1");
                    }
                    if (qualifierNameWhenCustomSchemaIsSet != null) {
                        qualifierName = qualifierNameWhenCustomSchemaIsSet;
                        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[GET_TABLE_DEFINITION],
                                                                "Database being used is DB2 and UsingCustomSchemaName is set to true. The following qualifier name obtained from " +
                                                                                "running the query VALUES (CURRENT SCHEMA) will be used for subsequent queries in this method: "
                                                                                + qualifierNameWhenCustomSchemaIsSet);
                        }
                    }
                } // Oracle case to be handled later
            } //PM27191 END
        }

        ResultSet rs1 = dmd.getColumns(null, qualifierName, tbName, "%");
        try {
            while (rs1.next()) {
                String columnname = rs1.getString("COLUMN_NAME");
                int columnsize = rs1.getInt("COLUMN_SIZE");
                if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[GET_TABLE_DEFINITION], "COLUMN_NAME = " + columnname + " COLUMN_SIZE = " + Integer.toString(columnsize));
                }
                if (columnname.equalsIgnoreCase("SMALL")) {
                    smallColSize = columnsize;
                    smallExists = true;
                }
                if (columnname.equalsIgnoreCase("MEDIUM")) {
                    if (!usingOracle) { // cmd 162172 long raw or Blob
                                        // does not give proper size from
                                        // COLUMN_SIZE data for Oracle
                        mediumColSize = columnsize;
                    }
                    mediumExists = true;
                }
                if (columnname.equalsIgnoreCase("LARGE")) {
                    largeColSize = columnsize;
                    largeExists = true;
                }
                defExists = true;
            }

            if (defExists) {
                if (smallExists && mediumExists && largeExists) {
                    if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
                        LoggingUtil.SESSION_LOGGER_WAS.logp(Level.FINE, methodClassName, methodNames[GET_TABLE_DEFINITION], "Table exists with all the required columns");
                    }
                } else {
                    //Flag the error
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[GET_TABLE_DEFINITION], "DatabaseHashMap.wrongTableDef");
                }
            }
        } finally {
            closeResultSet(rs1);
        }
        return defExists;
    }
920756
def has_table(self, table):
        
        sql = self._grammar.compile_table_exists()

        table = self._connection.get_table_prefix() + table

        return len(self._connection.select(sql, [table])) > 0
1062602
public function sqlFrom()
    {
        if (!$this->hasTable()) {
            throw new UnexpectedValueException(
                'Can not get SQL FROM clause. No table defined.'
            );
        }

        $table = $this->table();
        return '`'.$table.'` AS `'.self::DEFAULT_TABLE_ALIAS.'`';
    }
1324615
def get_column_listing(self, table):
        
        sql = self._grammar.compile_column_exists()
        database = self._connection.get_database_name()
        table = self._connection.get_table_prefix() + table

        results = []
        for result in self._connection.select(sql, [database, table]):
            new_result = {}
            for key, value in result.items():
                new_result[key.lower()] = value

            results.append(new_result)

        return self._connection.get_post_processor().process_column_listing(results)
1332577
def sql(self, dialect=None, inserts=False, creates=True,
            drops=True, metadata_source=None):
        
        result = [self.ddl(dialect, creates=creates, drops=drops)]
        if inserts:
            for row in self.inserts(dialect):
                result.append(row)
        return '\n'.join(result)
229764
def table(self, name, database=None):
        
        qualified_name = self._fully_qualified_name(name, database)
        schema = self._get_table_schema(qualified_name)
        node = self.table_class(qualified_name, schema, self)
        return self.table_expr_class(node)
899216
public function getDefinitionTable()
    {
        $definition = array_merge(
            $this->getIndex()->getDefinition(),
            $this->getDefinitionSecondaryIndexes()
        );

        $definition['TableName']            = $this->getTableName();
        $definition['AttributeDefinitions'] = $this->getDefinitionIndexAttributes();

        return $definition;
    }
977630
def table(self, name):
        
        qualified_name = self._qualify(name)
        return self.client.table(qualified_name, self.name)
307450
def tables(self):
        """"""
        tables = []
        self.cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
        for table_info in self.cursor.fetchall():
            if table_info[0] != 'sqlite_sequence':
                tables.append(table_info[0])
        return tables