sql-drop

Changing data type of column in SQL Server

主宰稳场 提交于 2019-12-12 01:22:29
问题 I have to change datatype of a column in SQL Server. So what are the constraints in doing? I know I have to remove index and other constraints? Do I have to remove not null check ? What other things do I have to check before altering the datatype? I need to remove the constraints and alter the table and then add the constraints again. Is this the right way to do so ? DROP INDEX UX_1_COMPUTATION ON dbo.Computation ALTER TABLE dbo.Computation ALTER COLUMN ComputationID NVARCHAR(25) CREATE

sql DROP CONSTRAINT UNIQUE not working

為{幸葍}努か 提交于 2019-12-11 23:59:38
问题 I got the following table: CREATE TABLE `unsub_counts` ( `count_id` int(11) NOT NULL AUTO_INCREMENT, `unsub_date` date DEFAULT NULL, `unsub_count` int(11) DEFAULT NULL, `store_id` smallint(5) DEFAULT NULL, PRIMARY KEY (`count_id`), UNIQUE KEY `uc_unsub_date` (`unsub_date`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; where column unsub_date is unique . Now I want to drop that uniqueness, because I need to have a unique index on unsub_date + store_id . I found suggestions on the net, but is failing:

how to change permission for the service account in azure's sql management portal

情到浓时终转凉″ 提交于 2019-12-11 14:37:47
问题 I want to delete an entry from my sql table, through Azure's sql management portal. When I query "DROP USER "XXX" " it says "Cannot drop the user 'XXX', because it does not exist or you do not have permission." Where can I change permission for the service account to delete entries from table? 回答1: I'm assuming this question is related to your previous question (how to delete an entry from azure sql?). DROP USER will try to remove a user which has access to your database, this has nothing to

What happens to an existing DB2 view, if the table is dropped?

流过昼夜 提交于 2019-12-11 07:48:03
问题 If we have created a view on an existing DB2 table and then drop the table. What will happen to the view ? 回答1: The view becomes invalid/inoperative. Attempts to select from it will fail. To try it: create table TEST_TABLE ( TEST_COL INTEGER ); INSERT INTO TEST_TABLE VALUES(1); SELECT * FROM TEST_TABLE; create view TEST_VIEW AS SELECT * FROM TEST_TABLE; SELECT * FROM TEST_VIEW; DROP TABLE TEST_TABLE; SELECT * FROM TEST_VIEW; The last statement gives the error: [IBM][CLI Driver][DB2/NT]

How to drop many (but not all) tables in one fell swoop?

五迷三道 提交于 2019-12-11 01:05:36
问题 I have a database with many tables. Twelve of these tables start with the same prefix: mystuff_table_1 mystuff_table_2 mystuff_table_3 mystuff_table_4 etc... I don't want to type DROP TABLE mystuff_table_n CASCADE; over and over again, especially since I have to repeatedly drop the tables. How can I make my life easier? 回答1: First of all, you can delete many tables in a single statement: DROP TABLE mystuff_table_1, mystuff_table_2, mystuff_table_3 CASCADE; Next, you could put all of those

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

被刻印的时光 ゝ 提交于 2019-12-09 16:11:30
问题 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? 回答1: mysql_query('DROP TABLE IF EXISTS `dbName`.`tableName`') or die(mysql_error()); 回答2: You should use backticks instead of double quotes like this: mysql_query('DROP TABLE IF EXISTS `dbName`.`tableName`'); 回答3: You can't use double quotes to

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

我的未来我决定 提交于 2019-12-09 08:21:56
问题 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? 回答1: It depends on how

MySQL Dropping Tables

拥有回忆 提交于 2019-12-07 18:01:40
问题 What syntax for MySQL would I use to drop multiple tables that have a similar pattern to them? Something like: DROP TABLES FROM `Database1` LIKE "SubTable*" 回答1: No. But you can select tables names from information_schema database: select table_name from information_schema.tables where table_schema = 'Database1' and table_name like 'SubTable%' And after that iterate the table names in result set and drop them 回答2: Since DROP TABLE was supported by prepared statements, it can be done in this

DROP TABLE fails for temp table

本小妞迷上赌 提交于 2019-12-07 06:56:42
问题 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

MySQL Dropping Tables

倾然丶 夕夏残阳落幕 提交于 2019-12-05 20:00:58
What syntax for MySQL would I use to drop multiple tables that have a similar pattern to them? Something like: DROP TABLES FROM `Database1` LIKE "SubTable*" No. But you can select tables names from information_schema database: select table_name from information_schema.tables where table_schema = 'Database1' and table_name like 'SubTable%' And after that iterate the table names in result set and drop them Since DROP TABLE was supported by prepared statements, it can be done in this way - SET @tables = NULL; SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables FROM information_schema