Pro tip for DELETE queries
If you're ever running something like this
DELETE FROM bigtable WHERE secretfield = 1;
in production the way I always do this is to type out the query without the table name ("bigtable") or the condition ("1").
That means if you accidentally hit Enter at an inopportune moment e.g. after just DELETE FROM bigtable (which would delete all rows!) the query will fail because it's syntactically invalid.
I then go back and add in the table name with a sanity check of "is this the table I really mean?" followed by the same with the conditions. Pause. Then press Enter.
Takes about 5 seconds longer and I've never once deleted something inadvertently in production. Oh, and never copy/paste queries for exactly this reason - unless you modify them to remove the same params first. //
Re: Pro tip for DELETE queries
or you could just start with SELECT * , and see if the results correspond with what you wanted to delete
then bring the DELETE in once you're happy the filters/ table/ db are all correct
or at the minimum type the WHERE field = 1 first to avoid accidentally hitting enter and doing a wholesale delete with no filter. //
Pro tip for DELETE queries
Always always do the Select Count first, then run at least three queries - select count, delete, select count and select any other useful where to prove the delete or the surviving records - all wrapped in a transaction to give yourself chance to check that you’re getting what you expect. Then go for a coffee, come back and check it again before swapping rollback for commit. //
Pro tip for DELETE queries
I can appreciate your imagination, but there are just too many steps where things can completely go wrong.
The only solution that works is to wrap things in a transaction. That's what they are there for, after all.
Certainly, checking the number of rows delete is an important sanity check. But not the only thing that might be checked. //
Re: Pro tip for DELETE queries
First do the SELECT FROM bigtable WHERE <condition> bit, then when you have verified that, do a SELECT INTO bigtable_backup_todaysdate FROM bigtable (without the WHERE clause) before changing it to a DELETE statement. If the database has active transactions going on, you might also want to make sure that either everyone else is out of the database, or you might want to consider using a query locking hint, such as WITH READUNCOMMITTED.
You can always do a DROP TABLE bigtable_backup_todaysdate later, once you've established you didn't screw up.
This does, of course, assume you have enough space in your database for a copy of "bigtable", but to be honest, if you don't have that much headroom (or log space) in your database, you're likely to run into bigger problems. //
Re: Pro tip for DELETE queries
How's this for a pro tip: always Always ALWAYS surround your PROD statements with begin transaction / rollback transaction FIRST?
begin transaction
delete from bigtable where secretfield=1
rollback transaction
See how many records are impacted. If it's more than you think, carefully query the data and understand why.
Finally, when you are done, replace "rollback" with "commit":
begin transaction
delete from bigtable where secretfield=1
commit transaction
But even before you do this, do a SELECT with the same criteria as the DELETE and actually read some records.
Visualize your DB via one-single query
Free and open source, DB design editor. No signup -> get a diagram in just 15sec
All without database access
Editor
Faster and easier Database diagramming
Build diagrams with a few clicks, see the full picture, export SQL scripts, customize your editor, and more.
Syntax diagrams - Backus Normal Form (BNF)
The syntax definitions on this site use a variant of Backus Normal Form (BNF) that includes the following:
In this tutorial, I'll explain how to create a custom Inventory software without coding, using DaDaBIK.
DaDaBIK is a low-code now-code development platform; it's a general-purpose platform so you can use it to build any data-based applications. An Inventory Management app is just one example of application you can build with DaDaBIK.
What is an Inventory Management System (IMS)?
An Inventory Management System helps you managing your warehouse, tracking stock levels and stock movements and giving precious information such as what products are understock.
Introduction to SQL, a 30-minutes Tutorial to learn the basics
Responsive and adaptive
PHP Generator for MySQL allows you to create applications that look fine on any device from a mobile phone to an extralarge desktop.
MySQL is among most widely-used and popular database technologies, so quite a lot of tools have been created in order to make the processes of designing, creating, and administering databases easier and more convenient. However, with all of the possible options, it can be difficult to choose one tool that will fit your requirements best.
Connecting a MySQL database with a PHP website can be challenging, especially for beginners. Developers must ensure they have the correct credentials and that the connection is properly configured.
After the connection is set up, developers may encounter errors when retrieving or manipulating data from the database. Debugging these errors can be time-consuming. Security is also a major concern to prevent unauthorized access to sensitive data.
In this tutorial, we'll build a RESTful CRUD application with PHP & MySQL in the backend and Vue.js in the frontend. We'll also be using Axios for sending Ajax request to PHP from Vue.
The Vue.js library, Axios client and Ajax technology allows you to fetch and display data in your application without the need to refresh the whole page each time.
DaDaBIK is a no-code / low-code development platform that can be used to quickly develop any type of data-driven application without coding.
Instead of writing your application using a programming language (such as PHP, Python or Java) you can build the application using a "point and click" approach, even if you don't have any coding skill (that's why no-code): starting from a database (MySQL, PostgreSQL, SQLite or Microsoft SQL Server) or from an Excel file you can generate a basic Web data-entry application in minutes and then customize it with very little effort.
Welcome to SQL Fiddle. A SQL database playground for:
- SQL Server
- SQLite
- PostgreSQL
- MySQL
- MariaDB
all the tags from https://b.plas.ml
1st-amendment 2nd-amendment 4th-amendment 5th-amendment 9/11 a8 abortion acl adhd afghanistan africa a/i air-conditioning amateur-radio amazon america american android animals anti-americanism antifa anti-semitism antiv antivirus aoip apollo apple appliances archaeology architecture archive art astronomy audio automation avatar aviation backup bash batteries belleville bible biden bill-of-rights biology bookmarks books borg bush business calibre camping capitalism cellphone censorship chemistry children china christianity church cia clinton cloud coldwar communication communist composed computers congress conservatives constitution construction cooking copyleft copyright corruption cosmology counseling creation crime cron crypto culture culture-of-death cummins data database ddt dd-wrt defense democrats depression desantis development diagrams diamonds disinformation diy dns documentation dokuwiki domains dprk drm drm-tpm drugs dvd dysautonomia earth ebay ebola ebook economics education efficiency electricity electronics elements elwa email energy engineering english environment environmentalism epa ethernet ethics europe euthanasia evolution faa facebook family fbi fcc feminism finance firewall flightsim flowers fonts français france fraud freebsd free-speech fun games gardening genealogy generation generators geography geology gifts git global-warming google gop government gpl gps graphics green-energy grounding hdd-test healthcare help history hollywood homeschool hormones hosting houses hp html humor hunting hvac hymns hyper-v imap immigration india infosec infotech insects instruments interesting internet investing ip-addressing iran iraq irs islam israel itec j6 journalism jumpcloud justice kindle kodi language ldap leadership leftist leftists legal lego lgbt liberia liberty linguistics linux literature locks make malaria malware management maps markdown marriage mars math media medical meshcentral metatek metric microbit microsoft mikrotik military minecraft minidisc missions moon morality mothers motorola movies mp3 museum music mythtv names nasa nature navigation navy network news nextcloud ntp nuclear obama ocean omega opensource organizing ortlip osmc oxygen paint palemoon paper parents passwords patents patriotism pdf petroleum pets pews photography photo-mgmt physics piano picasa plesk podcast poetry police politics pollution pornography pots prayer pregnancy presentations press printers privacy programming progressive progressives prolife psychology purchasing python quotes rabbits rabies racism radiation radio railroad reagan recipes recording recycling reference regulations religion renewables republicans resume riots rockets r-pi russia russiagate safety samba satellites sbe science sci-fi scotus secularism security servers shipping ships shooting shortwave signal sjw slavery sleep snakes socialism social-media software solar space spacex spam spf spideroak sports ssh statistics steampowered streaming supplement surveillance sync tarsnap taxes tck tds technology telephones television terrorism tesla theology thorium thumbnail thunderbird time tls tools toyota trains transformers travel trump tsa twitter typography ukraine unions united.nations unix ups usa vaccinations vangelis vehicles veracrypt video virtualbox virus vitamin vivaldi vlc voting vpn w3w war water weather web whatsapp who wifi wikipedia windows wordpress wuflu ww2 xigmanas xkcd youtube zfs