SQL
SQL
C
Unique
Primary key
Fees decimaldefault1000
Checkfees >= 1000
Not null
DDL Commands
SHOW TABLES;
DESC stu;
PDATE
U table_name
SET
column1
=
value1
,
column2
=
value2
, ...
WHERE
condition
;
I ) Adding column:
ALTER TABLE<TABLE NAME> ADD (<COLUMN_NAME><DATA
TYPE>[SIZE]);
elect <column name or *> from table where (columnname) >= 45 order by (column
S
name);
Where in (hello, no);
ggregate functions:
A
avg – to compute the average value
min – to find the minimum value
max – to find the maximum value
Sum – to find the total value
Stddev – to find the standard deviation
Count(column) – to count non-null values in a column
Count(*) – to count the total number of rows in a table
OREIGN KEY
F
SELECT M1.M_Id, M1.M_Name, M2.M_Qty, M2.M_Supplier FROM MobileMaster
M1, MobileStock M2 WHERE M1.M_Id=M2.M_Id AND M2.M_Qty>=300;
a.commit()
End current transaction and make all changes performed in the transaction permanent
a.rollback()
Undoes every command till after commit (since those are permanent now)
a.rowcount()
Returns the number of rows updated, inserted, deleted… ?
a.fetchone()
Retrieves the next row of a query result set and returns a single sequence
[reading data one by one]
a.fetchall()
Fetches all rows from the last executed statement in a tuple
a.fetchmany(n)
a.close()
Closes the connection