Hacker Community

Would you like to know the success stories of legendary hackers. This blog will discuss the final trick hackers. And prevent hacker attacks?

A brief MySQL tutorial

Creating and Deleting Databases

1) Creating a database mysql> CREATE database 134a; Query OK, 1 row affected (0.00 sec)
2) Deleting a database mysql> DROP database 134a; Query OK, 0 rows affected (0.00 sec)

Creating a Table

3) After we have created the database we use the USE statement to change the current database; mysql> USE 134a; Database changed
4) Creating a table in the database is achieved with the CREATE table statement mysql> CREATE TABLE president (
-> last_name varchar(15) not null,
-> first_name varchar(15) not null,
-> state varchar(2) not null,
-> city varchar(20) not null,
-> birth date not null default '0000-00-00',
-> death date null
-> );
Query OK, 0 rows affected (0.00 sec)

Examining the Results

5) To see what tables are present in the database use the SHOW tables:
mysql> SHOW tables;
+----------------+
| Tables_in_134a |
+----------------+
| president |
+----------------+
1 row in set (0.00 sec)
6) The command DESCRIBE can be used to view the structure of a table
mysql> DESCRIBE president;
+------------+-------------+------+-----+------------+-------+---------------------------------+
| Field | Type | Null | Key | Default | Extra | Privileges |
+------------+-------------+------+-----+------------+-------+---------------------------------+
| last_name | varchar(15) | | | | | select,insert,update,references |
| first_name | varchar(15) | | | | | select,insert,update,references |
| state | char(2) | | | | | select,insert,update,references |
| city | varchar(20) | | | | | select,insert,update,references |
| birth | date | | | 0000-00-00 | | select,insert,update,references |
| death | date | YES | | NULL | | select,insert,update,references |
+------------+-------------+------+-----+------------+-------+---------------------------------+

0 comments:

Post a Comment