Short tutorial about how to deal with MYSQL databases.
Query OK, 1 row affected (0.00 sec)
dexterserver is the name of the database.
Database changed
Here table has 4 fields id (numeric field) , first_name (character type field) , last_name (character type field), email (character type field), country (character type field).
Query OK, 0 rows affected (0.27 sec)
Records: 0 Duplicates: 0 Warnings: 0
select * from dexter;
mysql> delete from dexter where first_name = 'ronak' ;
UPDATE dexter SET id = 5 WHERE first_name = 'Rohit';
Query OK, 0 rows affected (0.03 sec)
- Creating Database
Query OK, 1 row affected (0.00 sec)
- Show list of all the databases.
- Accessing or using a particular database.
Database changed
- Creating table.
Here table has 4 fields id (numeric field) , first_name (character type field) , last_name (character type field), email (character type field), country (character type field).
- Listing all the tables in the database.
- You can view the columns you have created in the table “dexter” as:
- We will add a column say ‘last_name‘ after column ‘first_name‘.
Query OK, 0 rows affected (0.27 sec)
Records: 0 Duplicates: 0 Warnings: 0
- Inserting a row in the table.
- listing all the entries in a table we use * for all.
- Deleting a row using the id field here id field is numeric.
- deleting a row using the field which has character value, for character we have to use ' '.
Query OK, 1 row affected (0.02 sec)
- Updating a field in the table
- Deleting a column from the table.
- Deleting an existing table. mysql> drop table dexter;
- Renaming an existing table.
Query OK, 0 rows affected (0.04 sec)
Query OK, 0 rows affected (0.03 sec)
- Creating primary key with auto increment, In auto increment it automatically adds 1 to the last value is nothing is provided.
mysql> CREATE TABLE dexterserver ( id Int(3) NOT NULL AUTO_INCREMENT PRIMARY KEY , name Varchar (15));
For inserting data we have to mention the column name in insert command.
INSERT INTO dexterserver (name) VALUES ('Ronak');
No comments:
Post a Comment
Do Write about the Blog and Welcome to the world where open source is every thing :-)