473,411 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

how to delete database

exoskeleton
104 100+
good day dear expert...here i am again...i have a problem on how to delete database!

$hostname="localhost";
$database="exo";

if( !$pg_con=pg_connect("host=$hostname dbname=$database user=user1 password=pass1") ) {
print "Error : connect to ${hostname}<br>";
exit;
}

$del_database = "DROP DATABASE db_yy";
$exec = pg_exec($del_database);

is this correct? another thing is...how to connect to server? i connect with the usual way having database to connect to just like above written. but here of course i think you just need to connect to server in order to delete database. but i dont know how...please help

BTW im using postgre

TIA
Mar 5 '07 #1
3 1836
ak1dnar
1,584 Expert 1GB
Try this You can use the same Coding for Create,Drop,Delete Databases by
changing your mysql_query .
Convert this to pg SQL :)

$con is for Connect to the server with your userName and Password

[PHP]
<?php
$con = mysql_connect("localhost","userName_Here","Passwor d_Here");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

if (mysql_query("DROP DATABASE Your_DB_NAME_HERE",$con))
{
echo "Database Deleted";
}
else
{
echo "Error deleting database: " . mysql_error();
}

mysql_close($con);
?>[/PHP]
Mar 5 '07 #2
exoskeleton
104 100+
Try this You can use the same Coding for Create,Drop,Delete Databases by
changing your mysql_query .
Convert this to pg SQL :)

$con is for Connect to the server with your userName and Password

[PHP]
<?php
$con = mysql_connect("localhost","userName_Here","Passwor d_Here");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

if (mysql_query("DROP DATABASE Your_DB_NAME_HERE",$con))
{
echo "Database Deleted";
}
else
{
echo "Error deleting database: " . mysql_error();
}

mysql_close($con);
?>[/PHP]
thank you very sir... :) i really appreciate it...more power
Mar 5 '07 #3
savanm
85
Hi

Try this one...
[php]
<?php

$conn = ("localhost","username","password");

mysql_connect($conn) or die("the connection failed");

$query = ("DROP database databasename",$conn);


?>[/php]

Thanks
Navas
Mar 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
2
by: Bob Ganger | last post by:
Hello, I am working on a project using SQL Server 2000 with a database containing about 10 related tables with a lot of columns containing text. The total current size of the database is about...
7
by: Mike & Dyan | last post by:
I was able to figure out how to insert new data into my database. But for some reason and a lot of reading I can't seem to figure out how to delete any data. My app is going to be used for...
9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
3
by: John Rivers | last post by:
Hello, I think this will apply to alot of web applications: users want the ability to delete a record in table x this record is related to records in other tables and those to others in...
13
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
3
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
36
by: pearl146 | last post by:
Hi, I have some database files (.MDF, .LDF,...) on the server. When I try to delete them, the warning "Cannot delete file: There has been a sharing violation. The source or destination file may...
10
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.