CREATE DATABASE cm_devices;
USE cm_devices;
CREATE TABLE devices (deviceID int, deviceName varchar(50), price decimal);
SHOW tables;
SHOW columns FROM devices;
CREATE DATABASE cm_devices;
USE cm_devices;
CREATE TABLE devices (deviceID int, deviceName varchar(50), price decimal);
SHOW tables;
SHOW columns FROM devices;
CREATE TABLE address(id int not null, street varchar(255), postcode varchar(10), town varchar(30) default "Harrow");
The DEFAULT keyword used in this statement is followed by the default value “Harrow” for the town name column in the Address table. In this case, if Mr. Carl Merkel wants to insert data into this table, then there is no need to type “Harrow” for any customer who lives in this town as it will be inserted automatically.
Alter Table students ADD(age INT, country Varchar(10), nationality Varchar);
Alter Table students Drop Column nationality;
Alter Table students Modify country Varchar(88);
Update table_name
Set col_name =' Harper Building'
Where department = ' engineering'
INSERT INTO table_name (col1_name,col2_nam, col3_name)
Values
(value1, value2, value3),
(value1, value2, value3),
(value1, value2, value3);
Transpose
Insert Into targettable(newname) Select oldcolumnname From sourcetable
Delete From table_name
Where col_name = 'Millar'
ChatGPT
Yes, TRUNCATE TABLE is another SQL command that can delete all records from a table without deleting the table itself. Unlike DELETE FROM, which removes rows one by one and can be rolled back using transaction logs, TRUNCATE TABLE is a faster operation that removes all rows in a single operation and cannot be rolled back within a transaction.
So, both DELETE FROM and TRUNCATE TABLE can effectively clear all records from a table while leaving the table structure intact.
Congratulations @sweethoney! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
Your next target is to reach 500 comments.
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out our last posts: