Foros del Web » Programando para Internet » PHP »

funcion para control de tabla

Estas en el tema de funcion para control de tabla en el foro de PHP en Foros del Web. Hola, esa es la cosa como puedo saber si una tabla existe o no? en mysql. necesito crear todos los meses una tabla nueva para ...
  #1 (permalink)  
Antiguo 25/04/2005, 15:25
 
Fecha de Ingreso: octubre-2004
Ubicación: Santiago de Chile
Mensajes: 504
Antigüedad: 19 años, 6 meses
Puntos: 0
De acuerdo funcion para control de tabla

Hola, esa es la cosa como puedo saber si una tabla existe o no? en mysql.
necesito crear todos los meses una tabla nueva para un historial, eso a partir de una fecha.
Atte
Mauricio

  #2 (permalink)  
Antiguo 25/04/2005, 15:32
Avatar de dwaks  
Fecha de Ingreso: agosto-2002
Ubicación: Panamá
Mensajes: 962
Antigüedad: 21 años, 8 meses
Puntos: 15
Esto te puede ayudar

Esto es una consulta sql que le pregunta a una base de datos las tablas que lo forman, alli te devuelve un recordset que puedes recorrer para ver si la nueva tabla existe.

Show Tables From nombredelaBD


Solo debes cambiar nombredelaBD por la base de datos tuya.

Saludos.
  #3 (permalink)  
Antiguo 25/04/2005, 16:09
Avatar de SAGITARIO  
Fecha de Ingreso: febrero-2005
Ubicación: Huancayo
Mensajes: 108
Antigüedad: 19 años, 2 meses
Puntos: 0
Hola

A lo mejor esto te ayuda amigo:
Cita:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
[table_options] [select_statement]

or

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name LIKE old_table_name;

create_definition:
col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
[PRIMARY KEY] [reference_definition]
or PRIMARY KEY (index_col_name,...)
or KEY [index_name] (index_col_name,...)
or INDEX [index_name] (index_col_name,...)
or UNIQUE [INDEX] [index_name] (index_col_name,...)
or FULLTEXT [INDEX] [index_name] (index_col_name,...)
or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
[reference_definition]
or CHECK (expr)

type:
TINYINT[(length)] [UNSIGNED] [ZEROFILL]
or SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
or INT[(length)] [UNSIGNED] [ZEROFILL]
or INTEGER[(length)] [UNSIGNED] [ZEROFILL]
or BIGINT[(length)] [UNSIGNED] [ZEROFILL]
or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
or CHAR(length) [BINARY]
or VARCHAR(length) [BINARY]
or DATE
or TIME
or TIMESTAMP
or DATETIME
or TINYBLOB
or BLOB
or MEDIUMBLOB
or LONGBLOB
or TINYTEXT
or TEXT
or MEDIUMTEXT
or LONGTEXT
or ENUM(value1,value2,value3,...)
or SET(value1,value2,value3,...)

index_col_name:
col_name [(length)]

reference_definition:
REFERENCES tbl_name [(index_col_name,...)]
[MATCH FULL | MATCH PARTIAL]
[ON DELETE reference_option]
[ON UPDATE reference_option]

reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT

table_options:
TYPE = {BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM | MYISAM }
or AUTO_INCREMENT = #
or AVG_ROW_LENGTH = #
or CHECKSUM = {0 | 1}
or COMMENT = "string"
or MAX_ROWS = #
or MIN_ROWS = #
or PACK_KEYS = {0 | 1 | DEFAULT}
or PASSWORD = "string"
or DELAY_KEY_WRITE = {0 | 1}
or ROW_FORMAT= { default | dynamic | fixed | compressed }
or RAID_TYPE= {1 | STRIPED | RAID0 } RAID_CHUNKS=# RAID_CHUNKSIZE=#
or UNION = (table_name,[table_name...])
or INSERT_METHOD= {NO | FIRST | LAST }
or DATA DIRECTORY="absolute path to directory"
or INDEX DIRECTORY="absolute path to directory"

select_statement:
[IGNORE | REPLACE] SELECT ... (Some legal select statement)

sobre todo esta parte !!
[IF NOT EXISTS]



Salu2

Última edición por SAGITARIO; 25/04/2005 a las 16:15
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:17.