MySQL: Creating and Listing a Table; Listing the Fields in a Table
To See the Tables in Your Database:
1. Type the following:
mysql> SHOW TABLES;
Empty set (0.00 sec)
NOTE: If you have not made any, then zero will appear.
To Create a Table:
1. Type the following:
mysql> CREATE TABLE Friends (name char(20), age integer);
Query OK, 0 rows affected (0.05 sec)
2. A table with two fields has now been created: an array of twenty characters, or a "name" field, and an integer, "age" field. You should see something like this when you ask to see your tables
mysql> SHOW TABLES;
3. You can now view the columns in your new table:
To Put Data into a Table:
1. Type the following to put a record in your table:
mysql> INSERT INTO Friends (name, age) values ('Tom' , 20);
Query OK, 1 row affected (0.03 sec)
2. Now you can view your record:
Referenced from: mySQL.com
13624
3/18/2024 3:56:19 PM