2. SQL-Create table Create table table_name(column_name1 datatype, column_name2 datatypeâŠâŠ) Eg: create table example (id int ,name varchar(10),address varchar(10)) Msg: Command(s) completed successfully.
3. SQL-Insert Values Insert into table_name(column1,column2,âŠ..)values(values1,values2,âŠ) Eg: insert into example (id,name,address) values(123,'xxxx','yyyyy') Msg: (1 row(s) affected)
4. SQL-Select Command select *from example Id name address 123 xxxxyyyyy 456 jjjjrrrr 456 iiiinnnn 567 eeeeffff
5. SQL-Alter Command Alter table table_name add or drop column_namedatatype Eg: alter table example add mobilenoint Msg: Command(s) completed successfully. Id name address mobileno 123 xxxxyyyyy NULL 456 jjjjrrrr NULL 888 iiiinnnn NULL 567 eeeeffff NULL
6. SQL-Update Command Update table_name set column_name=new value where column_name=any value Eg: Update example set id=888 where name='iiiiâ Msg: (1 row(s) affected) Id name address 123 xxxxyyyyy 456 jjjjrrrr 888 iiiinnnn 567 eeeeffff
7. SQL-Delete Command Delete table_name where coition Eg: delete example where id=888 Msg: (1 row(s) affected) Id name address mobileno 123 xxxxyyyyy NULL 456 jjjjrrrr NULL 567 eeeeffff NULL
8. SQL-Drop Command Drop table table_name Eg: drop table example Msg:Command(s) completed successfully.
10. SQL-Primary Key & foreign Key create table example (id intprimary key,namevarchar(10),address varchar(10)) A primary key is used to unique and Not Null identify each row in the table. create table example2 (salary int,expamountint, id int references example(id)) A foreign key is a referential constraint between two tables.Â
11. SQL-Primary Key & Foreign Key Id name address 123 rrrrtttt 369 klkliooo 456 iiiihhhh 7889 wswsweww Salary expamount id 10000 4235 7889 12369 8526 456 12369 865 456 65894 12589 123 Example (primary Key tale) Example2 (Foreign Key tale)
12. SQL-Primary Key & Foreign Key select name,address,salary from example e,example2 e2 where e.id=e2.id O/P Name address salary wswsweww 10000 iiiihhhh 12369 iiiihhhh 12369 rrrrtttt 65894
18. SQL-Stored Procedure select *from example Id name address 123 rrrrtttt 369 klkliooo 456 iiiihhhh 666 hghgyuyu 7889 wswsweww
19. SQL-JOINS SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables Inner Join Left Join Right Join Full Join
20. SQL-INNER JOIN The INNER JOIN keyword return rows when there is at least one match in both tables. SELECT column_name(s)FROM table_name1INNER JOIN table_name2ON table_name1.column_name=table_name2.column_name
21. SQL-INNER JOIN select name,address,salary from example inner join example2 on example.id=example2.id order by name Name address salary iiiihhhh 12369 iiiihhhh 12369 rrrrtttt 65894 Wswsweww 10000
22. SQL-LEFT JOIN The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2) SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.column_name=table_name2.column_name
23. SQL_LEFT JOIN select name,address,salary from example left join example2 on example.id=example2.id order by name Name address salary hghgyuyu NULL iiiihhhh 12369 iiiihhhh 12369 klkliooo NULL rrrrtttt 65894 wswsweww 10000
24. SQL-RIGHT JOIN The RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1) SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ON table_name1.column_name=table_name2.column_name
25. SQL_RIGHT JOIN select name,address,salary from example right join example2 on example.id=example2.id order by name Name address salary iiiihhhh 12369 iiiihhhh 12369 rrrrtttt 65894 wswsweww 10000
26. SQL-FULL JOIN The FULL JOIN keyword return rows when there is a match in one of the tables. SELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name
27. SQL-FULL JOIN select name,address,salary from example full join example2 on example.id=example2.id order by name Name address salary hghgyuyu NULL iiiihhhh 12369 iiiihhhh 12369 klkliooo NULL rrrrtttt 65894 wswsweww 10000