Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.9 kB
4
Indexable
Never
Difference between char and varchar datatype:
char: 1.char datypes is use for store chracter string of fixed length.
      2.better performance than varchar


varchar:1.varchar datype is used to store character string of variable length.
        2. low performance  than char


create database:
syntax:-
create database database_name;

for checking database:
command: show databases;
for work database
command- use dattabase_name 

-------------------------------------------------------------------------------
create table:
syntax:
create table table_name(
     column1 datatype,
     column2 datatype,
     -
     -
     column3 datatype
   );

exa;
show tables;  --table check
create table Employee(
    empid int,
    name varchar(30),
    salary int,
    dept varchar(20),
    gender char(2)

);
desc Employee; - table describe

----------------------------------------------------------------------------------------
comments in sql:
single line comment:
  -- comments

multiline comment :
/*  statemets */

----------------------------------------------------------------------------------------------------------------
insert value in table:
the value provide in sequence and values required for all column
syntax:- insert into tablename values(----)

insert into Employee values(1,"ram",20000,"it","ma");
------
sequence is not manadatory and missing values for column
syntax:
insert into table_name(column1,column2,-----columnn) values(value1,valu2,----valuen)

ex;-
insert into Employee(empid,name,salary,gender) values(1,"radhika",30000,'fe');
insert into Employee(name,empid,salary,gender) values("nikita",4,30000,'fe');
----
multiple row insert at one time:-

insert into Employee values(6,"ratna",20000,"hr","fe"),(7,'hari',3000,'finance','ma'),
(8,'jiyu',50000,"IT","ma");

Leave a Comment