Professional Documents
Culture Documents
Ansi - Sqls Lec 01
Ansi - Sqls Lec 01
--Inserting records
COMMIT;
--Displaying records
--Updating records
Question add one more column called address of varchar and size 30.
Store addresses in all the 4 records.
-----------------------------------------------------------------
Created a table without primary key
create table book_master
(
bookid varchar(5),
bookname varchar(20),
price int(5)
);
DESC book_master;
2) ALTER TABLE table1 ADD PRIMARY KEY(code); --adding a primary key to a table
--------------------------------------------------------
3) ALTER TABLE table1 ADD UNIQUE KEY(code); --adding unique key to a table
-------------------------------------------------
DESC employee_details;
-----------------------------------------------------------------------------------
-------------------
OTHER COMMANDS
1) CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
2) GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON bankaccount.* TO
'ctsuser'@'localhost';
3) GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
4) REVOKE ALL PRIVILEGES ON *.* FROM 'newuser'@'localhost';
5) REVOKE UPDATE, DELETE ON *.* FROM 'cts'@'localhost';
-----------------------------------------------------------------------------------
-------------------
SET SQL_SAFE_UPDATES=0 --To alter a table without putting primary key in where
clause
-----------------------------------------------------------------------------------
----------------------
UPDATE employee_details
set address='kolkata'
WHERE code='E0001'