sql-drop

How to drop unique in MySQL?

蓝咒 提交于 2019-11-26 18:52:58
问题 Create Table: CREATE TABLE `fuinfo` ( `fid` int(10) unsigned NOT NULL, `name` varchar(40) NOT NULL, `email` varchar(128) NOT NULL, UNIQUE KEY `email` (`email`), UNIQUE KEY `fid` (`fid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 I want to drop the unique key on email ,how? 回答1: Simply you can use the following SQL Script to delete the index in MySQL: alter table fuinfo drop index email; 回答2: There is a better way which don't need you to alter the table: mysql> DROP INDEX email ON fuinfo; where

MySQL DROP all tables, ignoring foreign keys

北城以北 提交于 2019-11-26 14:57:28
问题 Is there a nice easy way to drop all tables from a MySQL database, ignoring any foreign key constraints that may be in there? 回答1: I found the generated set of drop statements useful, and recommend these tweaks: Limit the generated drops to your database like this: SELECT concat('DROP TABLE IF EXISTS `', table_name, '`;') FROM information_schema.tables WHERE table_schema = 'MyDatabaseName'; Note: This does not execute the DROP statements, it just gives you a list of them. You will need to cut

DROP FUNCTION without knowing the number/type of parameters?

删除回忆录丶 提交于 2019-11-26 12:13:15
问题 I keep all my functions in a text file with \'CREATE OR REPLACE FUNCTION somefunction\' . So if I add or change some function I just feed the file to psql. Now if I add or remove parameters to an existing function, it creates an overload with the same name and to delete the original I need type in all the parameter types in the exact order which is kind of tedious. Is there some kind of wildcard I can use to DROP all functions with a given name so I can just add DROP FUNCTION lines to the top

SQL: deleting tables with prefix

£可爱£侵袭症+ 提交于 2019-11-26 11:48:24
问题 How to delete my tables who all have the prefix myprefix_ ? Note: need to execute it in phpMyAdmin 回答1: You cannot do it with just a single MySQL command, however you can use MySQL to construct the statement for you: In the MySQL shell or through PHPMyAdmin, use the following query SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) AS statement FROM information_schema.tables WHERE table_name LIKE 'myprefix_%'; This will generate a DROP statement which you can than copy and execute

SQL Server: drop table cascade equivalent?

拟墨画扇 提交于 2019-11-26 09:46:00
问题 In oracle, to drop all tables and constraints you would type something like DROP TABLE myTable CASCADE CONSTRAINTS PURGE; and this would completely delete the tables and their dependencies. What\'s the SQL server equivalent?? 回答1: I don't believe SQL has a similarly elegant solution. You have to drop any related constraints first before you can drop the table. Fortunately, this is all stored in the information schema and you can access that to get your whack list. This blog post should be

How to remove all MySQL tables from the command-line without DROP database permissions? [duplicate]

我们两清 提交于 2019-11-26 06:51:59
问题 This question already has answers here : MySQL DROP all tables, ignoring foreign keys (22 answers) Closed 5 years ago . How do I drop all tables in Windows MySQL, using command prompt? The reason I want to do this is that our user has access to the database drops, but no access to re-creating the database itself, for this reason we must drop the tables manually. Is there a way to drop all the tables at once? Bear in mind that most of the tables are linked with foreign keys so they would have

Oracle: If Table Exists

别来无恙 提交于 2019-11-25 23:45:20
问题 I\'m writing some migration scripts for an Oracle database, and was hoping Oracle had something similar to MySQL\'s IF EXISTS construct. Specifically, whenever I want to drop a table in MySQL, I do something like DROP TABLE IF EXISTS `table_name`; This way, if the table doesn\'t exist, the DROP doesn\'t produce an error, and the script can continue. Does Oracle have a similar mechanism? I realize I could use the following query to check if a table exists or not SELECT * FROM dba_tables where