How to Create Table show Example

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

To create a table in MySQL, you can use the CREATE TABLE statement followed by the table name and the list of columns with their data types and any constraints. Here’s an example:

sql
CREATE TABLE employees (
employee_id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
email VARCHAR(100) UNIQUE,
hire_date DATE,
salary DECIMAL(10, 2),
department_id INT
);

In this example:

  • employees is the name of the table.
  • employee_id is an integer column that auto-increments and serves as the primary key.
  • first_name and last_name are string columns for the employee’s name.
  • email is a unique string column for the employee’s email address.
  • hire_date is a date column for the employee’s hire date.
  • salary is a decimal column for the employee’s salary.
  • department_id is an integer column that references the department the employee belongs to.

You can customize the column names, data types, and constraints according to your requirements.