Questions tagged [drop-table]

The SQL command for deleting an entire table.

DROP TABLE is used in SQL to remove a table.

152 questions
1
vote
2 answers

How do I use Flyway so that if a table gets mistakenly dropped, on running the application again, the deleted table gets created?

I have a requirement where if a table of a DB gets mistakenly dropped, we need it back, with or without the data. We already use Flyway for migration, is there any way we can achieve this using Flyway or otherwise?
Diparati
  • 61
  • 1
  • 6
1
vote
4 answers

Unable to drop database in SQL Server 2012

I have created a sample database earlier and now I want to delete that database, but it is not getting deleted. I searched online but I didn't find any solution which is working. Using T-SQL, I tried: USE [Sample] ALTER DATABASE [Sample] SET…
Indranil
  • 2,229
  • 2
  • 27
  • 40
1
vote
1 answer

SQL Injection using PHP multi_query to DROP TABLE

I am trying to drop a table within a database using SQL injection through PHP. The PHP code submits a form to the Database with the following command and multi_query($sql): $sql = "INSERT INTO Student (StdNumber, FName, LName, DOB, PhoneNumber)…
Bartholomas
  • 51
  • 1
  • 10
1
vote
3 answers

T-SQL Drop all tables

I am trying to drop all tables in a database without having to do it in the proper order. From what I have read running the NOCHECK command will prevent foreign keys from being checked. However, even after running that I still get an error trying to…
Swazimodo
  • 1,147
  • 1
  • 15
  • 34
1
vote
1 answer

Dropping a list of tables with schemas specified in postgreSQL

I've read the documentation on this here so I'm 90% sure, but the docs don't explicitly say if there's a limit to the list size, or if lists can also have schema names in the name formatting. I just want to be positive before I accidentally mess up…
singmotor
  • 3,930
  • 12
  • 45
  • 79
1
vote
1 answer

SQL Code not running: Drop Tables and Organization issue maybe?

So, this is my code. When I attempt to compile it in the school provided engine, I've gotten a couple errors, and they do change each time I run it, but the one I currently have is this: ERROR 1064 (42000) at line 123: You have an error in your SQL…
Sierra
  • 327
  • 4
  • 11
1
vote
2 answers

Cannot delete or update a parent row: a foreign key constraint fails Error

i am trying to delete the table appusers, with the following command: drop table appusers; and i get the following error: Cannot delete or update a parent row: a foreign key constraint fails this is the scheme for my tables. CREATE TABLE appUsers…
Dan The Man
  • 1,835
  • 6
  • 30
  • 50
1
vote
2 answers

extra column in MySQL, can I drop it?

I have a database I'm creating and I made a 1 to 1 connection with another table in Mysql, below is a screen shot. My question is can I drop the extra column (assembly factory_id) that was created when I made the connection? I only want the single…
beau8008
  • 49
  • 1
  • 7
1
vote
0 answers

Can't drop table on Microsoft SQL Server Management Studio

I am new to working with Microsoft SQL Server Management Studio, and it is not letting me drop a table that I have created. I need to modify its primary keys, but it freezes when I try to do that as well and when I try to save the file it freezes.…
saupton
  • 297
  • 2
  • 4
  • 9
1
vote
1 answer

Best practices for using truncate vs drop for temp tables

So I have been researching SQL standards with regard to using TRUNCATE vs DROP. My company is trying to determine whether we should use TRUNCATE before a DROP as a standard coding convention, or if we should just use DROP. Typically, we have always…
1
vote
1 answer

Delete table with empty name in PostgreSQL

I'm trying to remove one of my tables stored in PostgreSQL 8.3.8 32bit. Strange is that my table doesn't have a name, it's empty. Where I do: SELECT * FORM pg_catalog.pg_tables; it says that me tablename name is null. When I try to delete my…
user2919480
  • 15
  • 1
  • 6
1
vote
1 answer

Check var is NULL in stored procedure

I have a script that deletes all tables. SET FOREIGN_KEY_CHECKS = 0; SET @tables = NULL; SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables FROM information_schema.tables WHERE table_schema = 'mydb'; SET @tables = CONCAT('DROP…
tmporaries
  • 1,523
  • 8
  • 25
  • 39
1
vote
2 answers

Create table script syntax error "table does not exist"

This is my first time producing a script which I can run through the psql terminal using the -f option. My script is as follows: DROP TABLE if EXISTS piste; DROP TABLE if EXISTS lift; DROP TABLE if EXISTS lift_location; CREATE TABLE piste ( …
chris edwards
  • 1,332
  • 4
  • 13
  • 31
1
vote
0 answers

Dropped and recreated the the table in SQL - Data not being read after that

I am a beginner level programmer who was assigned to update the data content in UI. this UI references a database table so I went ahead and began updating the table as per constraints. I had a backup of the data taken and had the create construct…
1
vote
1 answer

Error in foreign key constraint on a dropped table

When I execute the following SQL commands: CREATE TABLE `TableA` ( `tableAId` INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`tableAId`) ); CREATE TABLE `TableB` ( `tableBId` INT(11) NOT NULL AUTO_INCREMENT, `tableAId` INT(11) DEFAULT NULL, …
blemale
  • 11
  • 2