4. SQL
4. SQL
----------------
--------------------------------
Ex:
Books table
---------------------
---------------------
---------------------
-----------------
----------------
- DB/2 (IBM)
- Sybase (Microsoft)
---------------------------------------------
username : root
password : root
--------------------------
-----------------------------------------------------
Youtube link
------------
https://www.youtube.com/watch?v=m9UKmUK9BbA
Download and Install MySQL Server 8 on macOS
---------------------------------------------
https://www.youtube.com/watch?v=-BDbOOY9jsc
Creating a database
-------------------
syntax
------
Ex:
Use/Change Database
-------------------
mysql>use java16;
Drop database
-------------
Datatypes
---------
- int
- float
- char - used to store fixed size data Ex: empids, rollnos, itemnos etc
- varchar - used to store variable size data Ex: empnames, studnames, itemnames etc
- date
--------------------
syntax
------
column-2 datatype(size),
....
column-n datatype(size));
Ex:
desc command
-------------
Ex:
desc books;
syntax
------
EX:
Insert command
--------------
syntax
------
- the number of values should be equal to the number of columns given in the command
Ex:
update command
--------------
syntax
-------
[] => optional
Ex:
update books set price=600;//for all records price will be updated to 600
TCL Commands
------------
commit
------
Ex:
mysql>commit;
rollback
--------
Ex:
mysql>rollback;
Note
----
-------------------------------------
mysql>set autocommit = 0;
-------------------------------------
mysql>set autocommit = 1;
Delete command
---------------
syntax
-------
Ex:
select command
--------------
Ex:
-------------------
- rename columns
- drop columns