CREATE DATABASE
SyntaxCREATE DATABASE [IF NOT EXISTS] db_name
CREATE DATABASE
creates a database with the given name.
Rules for
allowable database names are given in section 6.1.2 Database, Table, Index, Column, and Alias Names. An error occurs if
the database already exists and you didn't specify IF NOT EXISTS
.
Databases in MySQL are implemented as directories containing files
that correspond to tables in the database. Because there are no tables in a
database when it is initially created, the CREATE DATABASE
statement
only creates a directory under the MySQL data directory.
You can also create databases with mysqladmin
.
See section 4.8 MySQL Client-Side Scripts and Utilities.
Posted by Kyle Holder on Thursday August 15 2002, @7:12pm | [Delete] [Edit] |
Is there a way to limit the size of a database
through MySql and not through the OS? Thanks...
KAH
Posted by [name withheld] on Tuesday March 4 2003, @1:47am | [Delete] [Edit] |
Can we change the name of a database. I think there should be such an option if we can rename a table a simmilar option should be given even for the database
Posted by Ron on Thursday March 6 2003, @2:24pm | [Delete] [Edit] |
I cant create database.. says "No Privieges" However I can create when going through my control panel on the server side. I can see my database have other functions, just can' create... Any suggestions would be greatly appreciated... Thanks..
Posted by Angel Oviedo Esquivel on Thursday March 13 2003, @2:14pm | [Delete] [Edit] |
Can I create a table from a text file for example
create table from ( I don't Known)
LOAD DATA INFILE '/home2/ancvw/procesos/FacturacionFeb2003.txt'
INTO TABLE edos_cuenta
FIELDS
TERMINATED BY '\t'
ENCLOSED BY '"';
any body know
Posted by Leland Olson on Wednesday April 16 2003, @9:03am | [Delete] [Edit] |
For those that are interested:
While I don't know about doing it from the command line, I do know you can create a script in PHP to create one or more tables from a file. I wrote just such a script and below is the code snippet that does the work. One note: in order to use it you need to end statements with a semicolon, but MySQL users should be doing this anyways.
//Get connection handle
$dblink = mysql_connect($host, $user, $pass);
//open sql file and pass it into a perl type RegEx
$sqlfile = file($sqlfilename);
$sqlfile = implode($sqlfile, "");
$elements=preg_match_all("([^;]*;)", $sqlfile, $match);
//loop through all matches and do the queries: Blue for success, Red for failure
for ($index=0; $index<$elements; $index++)
{
$dbresult = mysql_db_query($dbname, $match[0][$index], $dblink);
if (is_bool($dbresult) and $dbresult==false)
{
print("<p><font color=#ff0000> {$match[0][$index]} </font></p>");
}
else
{
print("<p><font color=#0000ff> {$match[0][$index]} </font></p>");
}
}
mysql_close($dblink);
Posted by karthikeyan jeyabalan on Friday April 25 2003, @3:09am | [Delete] [Edit] |
is triggers concept supports in mysql 4.0
Posted by bente on Monday May 12 2003, @1:25am | [Delete] [Edit] |
you can easily create tables with a textfile in the following way:
mysql [dbname] < your_table_defs.sql
type yhis at the systems prompt, not the mysql prompt btw
even works when you have to login first:
mysql [dbname] -p < your_table_defs.sql