0% found this document useful (0 votes)
9 views7 pages

Dbms Expt6 Delta

The document shows SQL queries being run on the MySQL database, including selecting data from tables, describing tables, and using various string and date functions like SUBSTR, CONCAT, EXTRACT. Information like database names, table structure, and sample data is displayed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

Dbms Expt6 Delta

The document shows SQL queries being run on the MySQL database, including selecting data from tables, describing tables, and using various string and date functions like SUBSTR, CONCAT, EXTRACT. Information like database names, table structure, and sample data is displayed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

mysql> use gauri;

Database changed
mysql> select current_date;
+--------------+
| current_date |
+--------------+
| 2024-04-02 |
+--------------+
1 row in set (0.00 sec)

mysql> select current_time;


+--------------+
| current_time |
+--------------+
| 13:31:40 |
+--------------+
1 row in set (0.00 sec)

mysql> use sakila;


Database changed
mysql> show tables;
+----------------------------+
| Tables_in_sakila |
+----------------------------+
| actor |
| actor_info |
| address |
| category |
| city |
| country |
| customer |
| customer_list |
| film |
| film_actor |
| film_category |
| film_list |
| film_text |
| inventory |
| language |
| nicer_but_slower_film_list |
| payment |
| rental |
| sales_by_film_category |
| sales_by_store |
| staff |
| staff_list |
| store |
+----------------------------+
23 rows in set (0.00 sec)

mysql> select * from store;


+----------+------------------+------------+---------------------+
| store_id | manager_staff_id | address_id | last_update |
+----------+------------------+------------+---------------------+
| 1 | 1 | 1 | 2006-02-15 04:57:12 |
| 2 | 2 | 2 | 2024-04-01 15:42:12 |
+----------+------------------+------------+---------------------+
2 rows in set (0.00 sec)

mysql> describe store;


+------------------+-------------------+------+-----+-------------------
+-----------------------------------------------+
| Field | Type | Null | Key | Default |
Extra |
+------------------+-------------------+------+-----+-------------------
+-----------------------------------------------+
| store_id | tinyint unsigned | NO | PRI | NULL |
auto_increment |
| manager_staff_id | tinyint unsigned | NO | UNI | NULL |
|
| address_id | smallint unsigned | NO | MUL | NULL |
|
| last_update | timestamp | NO | | CURRENT_TIMESTAMP |
DEFAULT_GENERATED on update CURRENT_TIMESTAMP |
+------------------+-------------------+------+-----+-------------------
+-----------------------------------------------+
4 rows in set (0.00 sec)

mysql> select store_id, date(last_update) from store;


+----------+-------------------+
| store_id | date(last_update) |
+----------+-------------------+
| 1 | 2006-02-15 |
| 2 | 2024-04-01 |
+----------+-------------------+
2 rows in set (0.00 sec)

mysql> select store_id, time(last_update) from store;


+----------+-------------------+
| store_id | time(last_update) |
+----------+-------------------+
| 1 | 04:57:12 |
| 2 | 15:42:12 |
+----------+-------------------+

mysql> select store_id, extract(day from last_update) from store;


+----------+-------------------------------+
| store_id | extract(day from last_update) |
+----------+-------------------------------+
| 1 | 15 |
| 2 | 1 |
+----------+-------------------------------+

mysql> select store_id, extract(year from last_update) from store;


+----------+--------------------------------+
| store_id | extract(year from last_update) |
+----------+--------------------------------+
| 1 | 2006 |
| 2 | 2024 |
+----------+--------------------------------+

mysql> select store_id, extract(hour from last_update) from store;


+----------+--------------------------------+
| store_id | extract(hour from last_update) |
+----------+--------------------------------+
| 1 | 4 |
| 2 | 15 |
+----------+--------------------------------+

mysql> select store_id, extract(minute from last_update) from store;


+----------+----------------------------------+
| store_id | extract(minute from last_update) |
+----------+----------------------------------+
| 1 | 57 |
| 2 | 42 |
+----------+----------------------------------+

mysql> select store_id, extract(second from last_update) from store;


+----------+----------------------------------+
| store_id | extract(second from last_update) |
+----------+----------------------------------+
| 1 | 12 |
| 2 | 12 |
+----------+----------------------------------+

mysql> select store_id, extract(month from last_update) from store;


+----------+---------------------------------+
| store_id | extract(month from last_update) |
+----------+---------------------------------+
| 1 | 2 |
| 2 | 4 |
+----------+---------------------------------+

mysql> select store_id, extract(week from last_update) from store;


+----------+--------------------------------+
| store_id | extract(week from last_update) |
+----------+--------------------------------+
| 1 | 7 |
| 2 | 13 |
+----------+--------------------------------+

mysql> select dayname ('2024-04-02');


+------------------------+
| dayname ('2024-04-02') |
+------------------------+
| Tuesday |
+------------------------+

mysql> select datediff ('2024-04-02', '2024-01-01');


+---------------------------------------+
| datediff ('2024-04-02', '2024-01-01') |
+---------------------------------------+
| 92 |
+---------------------------------------+

mysql> select ascii('A');


+------------+
| ascii('A') |
+------------+
| 65 |
+------------+
mysql> select ascii('Z');
+------------+
| ascii('Z') |
+------------+
| 90 |
+------------+

mysql> select ascii('a');


+------------+
| ascii('a') |
+------------+
| 97 |
+------------+

mysql> select ascii('z');


+------------+
| ascii('z') |
+------------+
| 122 |
+------------+

mysql> select ascii('s');


+------------+
| ascii('s') |
+------------+
| 115 |
+------------+

mysql> select ascii('0');


+------------+
| ascii('0') |
+------------+
| 48 |
+------------+

mysql> select ascii('9');


+------------+
| ascii('9') |
+------------+
| 57 |
+------------+

mysql> select ascii('@');


+------------+
| ascii('@') |
+------------+
| 64 |
+------------+

mysql> select ascii(' ');


+------------+
| ascii(' ') |
+------------+
| 32 |
+------------+

mysql> select ascii(';');


+------------+
| ascii(';') |
+------------+
| 59 |
+------------+

mysql> select bin(12);


+---------+
| bin(12) |
+---------+
| 1100 |
+---------+

mysql> select bit_length('Hello');


+---------------------+
| bit_length('Hello') |
+---------------------+
| 40 |
+---------------------+

mysql> select char_length('Hello');


+----------------------+
| char_length('Hello') |
+----------------------+
| 5 |
+----------------------+

mysql> select concat('Hello', 'World');


+--------------------------+
| concat('Hello', 'World') |
+--------------------------+
| HelloWorld |
+--------------------------+

mysql> select find_in_set('A', 'A, B, C, D');


+--------------------------------+
| find_in_set('A', 'A, B, C, D') |
+--------------------------------+
| 1 |
+--------------------------------+

mysql> SELECT upper('hello');


+----------------+
| upper('hello') |
+----------------+
| HELLO |
+----------------+

mysql> SELECT LOWER('HELLO');


+----------------+
| LOWER('HELLO') |
+----------------+
| hello |
+----------------+

mysql> select repeat('hello', 3);


+--------------------+
| repeat('hello', 3) |
+--------------------+
| hellohellohello |
+--------------------+

mysql> select repeat('hello ', '3');


+-----------------------+
| repeat('hello ', '3') |
+-----------------------+
| hello hello hello |
+-----------------------+

mysql> select replace('hello ', 'h', 'w');


+-----------------------------+
| replace('hello ', 'h', 'w') |
+-----------------------------+
| wello |
+-----------------------------+

mysql> select reverse('hello');


+------------------+
| reverse('hello') |
+------------------+
| olleh |
+------------------+

mysql> select strcmp('hello', 'world');


+--------------------------+
| strcmp('hello', 'world') |
+--------------------------+
| -1 |
+--------------------------+

mysql> select strcmp('world', 'hello');


+--------------------------+
| strcmp('world', 'hello') |
+--------------------------+
| 1 |
+--------------------------+

mysql> select strcmp('hello', 'hello');


+--------------------------+
| strcmp('hello', 'hello') |
+--------------------------+
| 0 |
+--------------------------+

mysql> select substr('hello', '2');


+----------------------+
| substr('hello', '2') |
+----------------------+
| ello |
+----------------------+

mysql> select substr('hello', '3');


+----------------------+
| substr('hello', '3') |
+----------------------+
| llo |
+----------------------+

mysql> select substr('hello','2','3');


+-------------------------+
| substr('hello','2','3') |
+-------------------------+
| ell |
+-------------------------+

mysql> select substr('hello','2','2');


+-------------------------+
| substr('hello','2','2') |
+-------------------------+
| el |
+-------------------------+
1 row in set (0.00 sec)

You might also like