Working with SQL as a data analyst is so fun and I really love it.
It is also very important to learn SQL if you want to work as a data analyst.
While working with SQL as a data analyst, a lot of times, we need to delete rows, columns, views, and other objects as well.
Today, let's discuss how you can delete objects from a database using SQL keywords.
𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝘁 𝗸𝗲𝘆𝘄𝗼𝗿𝗱𝘀/𝗰𝗼𝗺𝗺𝗮𝗻𝗱𝘀 𝘁𝗼 𝗱𝗲𝗹𝗲𝘁𝗲 𝗿𝗼𝘄𝘀 𝗮𝗻𝗱 𝗼𝘁𝗵𝗲𝗿 𝗼𝗯𝗷𝗲𝗰𝘁𝘀 𝗳𝗿𝗼𝗺 𝗮 𝗱𝗮𝘁𝗮𝗯𝗮𝘀𝗲 𝗶𝗻𝗰𝗹𝘂𝗱𝗲:
1. 𝗗𝗘𝗟𝗘𝗧𝗘
2. 𝗧𝗥𝗨𝗡𝗖𝗔𝗧𝗘
3. 𝗗𝗥𝗢𝗣
𝗟𝗲𝘁'𝘀 𝗱𝗶𝘀𝗰𝘂𝘀𝘀 𝗮𝗯𝗼𝘂𝘁 𝘁𝗵𝗲𝗺 𝗶𝗻 𝗮 𝗯𝗶𝘁 𝗱𝗲𝘁𝗮𝗶𝗹:
• 𝗗𝗘𝗟𝗘𝗧𝗘: It is used to delete rows from a table. If a WHERE clause is not provided in DELETE statements then it deletes all the rows from the table. Also, it doesn't free up the space occupied by the table.
𝗘𝘅𝗮𝗺𝗽𝗹𝗲:
DELETE FROM employees
WHERE fired_employee = 'Yes'
• 𝗧𝗥𝗨𝗡𝗖𝗔𝗧𝗘: It deletes all the rows from the table. It also clears the space that a table occupies. It is faster than DELETE. Also, in some databases, it cannot be rolled back unless it is used in a transaction.
𝗘𝘅𝗮𝗺𝗽𝗹𝗲:
TRUNCATE TABLE old_employees
• 𝗗𝗥𝗢𝗣: It is used for the deletion/removal of a database object. This command deletes all the rows present in the table and removes the complete table structure as well. It can also be used to delete databases
𝗘𝘅𝗮𝗺𝗽𝗹𝗲:
DROP DATABASE marketing
So, these are the keywords/commands that you can use to delete rows and other objects from the database as a data analyst.
Enjoy. Follow for more!
#DataAnalysis #SQLTips #SQLCommands #DatabaseManagement #DataAnalyst #SQLForData #DataCleaning #SQLSkills #DataScience #DataAnalystLife #TechTips #SQL #DataJobsUSA #SQLUSA #AnalyticsCareersUSA #DataAnalystUK #SQLUK #AnalyticsUK #DataAnalystEurope #SQLEurope #AnalyticsEurope #GlobalDataJobs #SQLWorldwide #DataScienceGlobal #AnalyticsCareersGlobal