sql-drop

PostgreSQL drop role fails because of default privileges

青春壹個敷衍的年華 提交于 2019-12-05 12:12:01
问题 I am trying to drop a role 'xyz' that was previously the owner of the schema with the same name 'xyz'. I altered the schema ownership as below, and run reassigned ownership just in case (although all tables were created by a different user with superuser power). So I run all these: alter schema xyz owner to postgres; reassign owned by xyz to postgres; alter default privileges in schema seeds revoke all on tables from xyz cascade; alter default privileges in schema seeds revoke all on

DROP TABLE fails for temp table

旧街凉风 提交于 2019-12-05 10:43:46
I have a client application that creates a temp table, the performs a bulk insert into the temp table, then executes some SQL using the table before deleting it. Pseudo-code: open connection begin transaction CREATE TABLE #Temp ([Id] int NOT NULL) bulk insert 500 rows into #Temp UPDATE [OtherTable] SET [Status]=0 WHERE [Id] IN (SELECT [Id] FROM #Temp) AND [Group]=1 DELETE FROM #Temp WHERE [Id] IN (SELECT [Id] FROM [OtherTable] WHERE [Group]=1) INSERT INTO [OtherTable] ([Group], [Id]) SELECT 1 as [Group], [DocIden] FROM #Temp DROP TABLE #Temp COMMIT TRANSACTION CLOSE CONNECTION This is failing

How to drop multiple databases in SQL Server

天涯浪子 提交于 2019-12-04 07:58:16
问题 Just to clarify, ths isn't really a question, more some help for people like me who were looking for an answer. A lot of applications create temp tables and the like, but I was surprised when Team Foundation Server created 80+ databases on my test SQL Server. TFS didn't install correctly, and kindly left me to clear up after it. Since each database had a naming convention, rather than delete each database by hand, I remembered how to use cursors and have written what I view to be the most

Drop a table column

故事扮演 提交于 2019-12-04 05:35:47
问题 Is the following correct? I am getting an error. <?php $form_id = $form->data['form_id']; $query = mysql_query(" ALTER TABLE 'email_history' DROP '$form_id'; ") or die(mysql_error()); ?> 回答1: Use ` (backtick) to delimit object names in MySQL. Try that ALTER TABLE `email_history` DROP `$form_id`; Note, I don't know php, but you can't parametrise DDL ( ALTER TABLE etc) 来源: https://stackoverflow.com/questions/8689324/drop-a-table-column

Can you DROP TABLE IF EXISTS by specifying database name with table?

三世轮回 提交于 2019-12-04 03:22:37
I am trying to drop a table in a database with the following query statement: mysql_query('DROP TABLE IF EXISTS "dbName.tableName"') or die(mysql_error()); But I keep getting an error. Does anyone know if specifying the dbName.tableName is invalid? mysql_query('DROP TABLE IF EXISTS `dbName`.`tableName`') or die(mysql_error()); You should use backticks instead of double quotes like this: mysql_query('DROP TABLE IF EXISTS `dbName`.`tableName`'); You can't use double quotes to quote db/table names, instead you either leave them unquoted or use backticks. But to answer your question, yes it is

Delete, Truncate or Drop to clean out a table in MySQL

北战南征 提交于 2019-12-03 15:13:14
问题 I am attempting to clean out a table but not get rid of the actual structure of the table. I have an id column that is auto-incrementing; I don't need to keep the ID number, but I do need it to keep its auto-incrementing characteristic. I've found delete and truncate but I'm worried one of these will completely drop the entire table rendering future insert commands useless. How do I remove all of the records from the table so that I can insert new data? 回答1: TRUNCATE will reset your auto

PostgreSQL: Drop Database but DB is still there

六月ゝ 毕业季﹏ 提交于 2019-12-03 14:48:50
问题 I am new to PostgreSQL and I try to get my head around it. I am familiar to db's and MySQL. I am trying to delete database, which I created since psql seems to ignore the changes I try to push through Django. When I execute \l I get the following response: List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ------------------+--------+----------+-------------+-------------+------------------- postgres | neurix | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 | test_db | neurix |

How to drop a list of SQL Server tables, ignoring constraints?

99封情书 提交于 2019-12-03 10:52:57
I have a list of half a dozen MSSQL 2008 tables that I would like to remove at once from my database. The data has been entirely migrated to new tables. There is no reference in the new tables to the old tables. The problem being that old tables comes with loads of inner FK constraints that have been autogenerated by a tool (aspnet_regsql actually). Hence dropping manually all constraints is a real pain. How can I can drop the old tables ignoring all inner constraints? Naveed Parvez It depends on how you want to drop the tables. If list of tables need to drop covers almost above 20 % of tables

Delete, Truncate or Drop to clean out a table in MySQL

空扰寡人 提交于 2019-12-03 04:52:41
I am attempting to clean out a table but not get rid of the actual structure of the table. I have an id column that is auto-incrementing; I don't need to keep the ID number, but I do need it to keep its auto-incrementing characteristic. I've found delete and truncate but I'm worried one of these will completely drop the entire table rendering future insert commands useless. How do I remove all of the records from the table so that I can insert new data? TRUNCATE will reset your auto-increment seed (on InnoDB tables, at least), although you could note its value before truncating and re-set

PostgreSQL: Drop Database but DB is still there

一个人想着一个人 提交于 2019-12-03 04:32:52
I am new to PostgreSQL and I try to get my head around it. I am familiar to db's and MySQL. I am trying to delete database, which I created since psql seems to ignore the changes I try to push through Django. When I execute \l I get the following response: List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ------------------+--------+----------+-------------+-------------+------------------- postgres | neurix | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 | test_db | neurix | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 | template0 | neurix | UTF8 | en_AU.UTF-8 | en_AU.UTF-8 | =c/neurix +