Science, Tech, Math › Computer Science MySQL Tutorial: Create SQL Tables Share Flipboard Email Print Computer Science PHP Programming MySQL Commands Tutorials Perl Python Java Programming Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Angela Bradley Angela Bradley Computer Science Expert B.A, History, Eastern Oregon University Angela Bradley is a web designer and programming expert with over 15 years of experience. An expert in iOS software design and development, she specializes in building technical hybrid platforms. Learn about our Editorial Process Updated on February 17, 2019 One of the easiest ways to create a table is through phpMyAdmin, which is available on most hosts that offer MySQL databases (ask your host for a link). First, you need to login to phpMyAdmin. 01 of 04 Create Tables in phpMyAdmin On the left hand side you will see "phpMyAdmin" logo, some small icons, and below them you will see your database name. Click on your database name. Now on the right hand side any tables you may have in your database will be displayed, as well as a box labeled "Create new table on database" Click this and create a database as we have in the diagram below. 02 of 04 Adding Rows and Columns Let's say we work in a doctor's office and wanted to make a simple table with a person's name, age, height, and the date we collected this information. On the previous page we entered "people" as the name of our table, and chose to have 4 fields. This brings up a new phpmyadmin page where we can fill in the fields and their types to add rows and columns. (See an example above) We have filled in the field names as: name, age, height, and date. We have set the data types as VARCAR, INT (INTEGER), FLOAT and DATETIME. We set a length of 30 on the name, and have left all other fields blank. 03 of 04 SQL Query Window in phpMyAdmin Perhaps a quicker way to add a table is by clicking on the small "SQL" button on the left hand side below the phpMyAdmin logo. This will bring up a query window where we can type our commands. You should run this command: As you can see, the command "CREATE TABLE" does exactly that, creates a table which we have called "people". Then inside the ( brackets ) we tell it what columns to make. The first is called "name" and is VARCAR, the 30 indicates we are allowing up to 30 characters. The second, "age" is an INTEGER, the third "height" is a FLOAT and the forth "date" is DATETIME. Regardless of which method you chose, if you would like to see a breakdown of what you just did click on the "people" link that now appears on the left hand side of your screen. On the right you should now see the fields you added, their data types, and other information. 04 of 04 Using Command Lines If you prefer you can also run commands from a command line to create a table. A lot of web hosts don't give you shell access to the server anymore, or allow remote access to the MySQL servers. If you want to do it this way you may have to install MySQL locally, or try this nifty web interface. First you will need to login to your MySQL database. If you are unsure how try using this line: mysql -u Username -p Password DbName Then you can run the command: To view what you have just created try typing in: describe people; No matter which method you chose to use, you should now have a table setup and ready for us to enter data into. Cite this Article Format mla apa chicago Your Citation Bradley, Angela. "MySQL Tutorial: Create SQL Tables." ThoughtCo, Aug. 26, 2020, thoughtco.com/mysql-tutorial-create-sql-tables-2693877. Bradley, Angela. (2020, August 26). MySQL Tutorial: Create SQL Tables. Retrieved from https://www.thoughtco.com/mysql-tutorial-create-sql-tables-2693877 Bradley, Angela. "MySQL Tutorial: Create SQL Tables." ThoughtCo. https://www.thoughtco.com/mysql-tutorial-create-sql-tables-2693877 (accessed June 7, 2023). copy citation