how to delete my database in a simple way - mysql

I want to delete my database used in my webhotel. How do I do?
I am a newbie, and have tried to find a way to do it, but without success.
Please assist me.
Reason is, I want to start all over.
Best regards, dolle

DROP database_name
If your database name is webhotel_db, you can run this command in your database client's query box:
DROP webhotel_db

You can try to delete your databases or tables from phpMyAdmin by using DROP.
There are two kinds of DROP buttons. You should select the appropriate one for your purpose.
1. Delete database:
phpMyAdmin > Click on the database you wish to delete (on the left of your screen) > Click on the DROP tab
Click to watch an example
2. Delete tables:
phpMyAdmin > Click on the database (on the left of your screen) > check the table and click DROP (you can find this DROP button on the same line as your table)
Click to watch an example

Related

What does generated by server on drop tables mean [duplicate]

Under the structure tab, when EXPORTing a database using phpmyadmin there is a check box labeled:
Add DROP TABLE / VIEW / PROCEDURE / FUNCTION
What does this do?
When creating a table, view, procedure, or function, it will add a DROP statement before it. The result of this is that even if the item exists, it will still be created.
For example: If you have a table called users and you run the export script without the DROP checkbox, it will attempt to create the users table again but will fail since it already exists. If you check it, it will drop the table before it is created (if it exists) to ensure the creation will always be successful.
Of course this can be dangerous if you have data in the table that you don't want to lose.
For example: If you have a table called users and you run the export script without the DROP checkbox, it will attempt to create the users table again but will fail since it already exists. If you check it, it will drop the table before it is created (if it exists) to ensure the creation will always be successful.
I was confused as to what this statement meant exactly, so I did additional research on the topic and wanted to leave an elaborated explanation here for future reference.
The create and drop actions in the above quote are simply instructions for when you import the file you have already exported. I was initially under the impression that these actions were happening as I was exporting. This is not the case. It's simply instructions for when you import your exported file.

In My SQL i want user to restrict the Drop table and Drop database

In mysql i want trigger for drop table and alter table, like in sql server we have.
FOR DROP_TABLE, ALTER_TABLE triggers
Is there any thing which i can do for it? basically i want the functionality that user should not able to delete/alter the table, we can even achieve it by providing restrictive permissions, But we have application in which the customer purchased the sql server so they have root user login and then can do it, so if we add trigger then only i think we can restrict it,
Same thing i need to drop database, In SQL server we have
FOR DROP_DATABASE , DROP_TRIGGER ,ALTER_TRIGGER
Is there any way to do it in mysql
Thanks in advance
You could use the REVOKE command to remove the ALTER and DROP permissions for the user.
https://dba.stackexchange.com/questions/27372/blocking-drop-database-command

how to create a view in database1, based on a table in database2

I'm using mysql and phpmyadmin.
I would like to create a view in database1 using a base table that exists in database2 on the same server.
What I've done so far is, I connect to database1 using phpmyadmin and run the following select statement:
select * from `database2`.`category`
That correctly displays the data from database2. Then i click on the "create view" link at the bottom of the page... but I can see that it's redirected me to database2. And when i click on OK to save the view, sure enough, it's been created in database2.
Can someone point me in the right direction?
Thanks
Have you tried executing this command in database1?
create view v_category as
select * from `database2`.`category`;

Change column order in MySQL

Is it possible to change the order of columns in MySQL (using phpMyAdmin XAMPP) by which they appear without dropping the current table?
Try this
ALTER TABLE `table_name`
MODIFY COLUMN `column_name1` varchar(100) AFTER `column_name2`;
I'm not sure about phpMyAdmin, but you can certainly do that with an SQL query:
ALTER TABLE `table`
CHANGE COLUMN `oldname` `newname` *column_definition* [AFTER|BEFORE] `colname`;
How to do it by using PhpMyAdmin:
Show table structure
On the relevant row (i.e. database column) click on "Modify"
On the extreme right, choose the new position form the "Move field" combo box
Optionally, click on "Show preview" to see what SQL query will be run (also useful for automatically repeating the procedure in another instance of the same database)
After closing the preview box, click on "Save"
Done!

Is it true I can't edit a MySQL trigger, I have to drop it and create a new one?

Is it true I can't edit a MySQL trigger, I have to drop it and create a new one?
Also, being a relative newcomer to triggers, it feels like they seem liable to causing 'erroneous' data. For example I might want a trigger to be fired (inserting data into another table) after one particular type of update query, but not others.
Any tips here gratefully received!
Edit: Yes, it is true that versions 5.n and 6.n of MySQL 5 & 6 implement CREATE TRIGGER and DROP TRIGGER and nothing else. According to this hunk of Postgres documentation, there is not even CREATE TRIGGER in SQL 92, so consider yourself lucky to have TRIGGER at all :-)
The Visual Studio MySQL plugin documentation has:
To modify an existing trigger, double click on a node of the trigger you wish to modify, or right click on this node and choose the Alter Trigger command from a context menu. Either of the commands opens the SQL Editor.
... which seems to do what you want. My guess is this is GUI sugar and behind the scenes you get a DROP CREATE.
As far as a trigger for some UPDATEs and not others, SQL has exactly one UPDATE per table. Put an IF clause at the start of your UPDATE trigger so that your logic - whatever you are doing in some of your UPDATEs - is only executed when you think it is appropriate.
MySQL has REPLACE TRIGGER, right?
As a sidenote.. Is it an issue? If you're worried queries are executed in between DROP and CREATE, you could always lock the table beforehand.
If you're using MySql Workbench it will allow you to alter the trigger. Just right click on your table name and click Alter table option from there you can pick Trigger option and alter it. Although, you cannot perform it from query mode.
Table Name --> Right Click --> Alter Table --> Triggers.