logo

Create a simple table in MySQL

MySQL Data Types

Category: MySQL

by designzone

2014-10-09 17:49:01

link: Full List of MySQL Data types

CREATE a table in MySQL using various data types:
CREATE TABLE sample (
  id bigint NOT NULL PRIMARY KEY AUTO_INCREMENT, 
  first_name varchar(64) NOT NULL, 
  middle_initial char, 
  last_name varchar(64) NOT NULL, 
  age int, 
  time_added datetime, 
  gpa decimal(6,4) NOT NULL
);

Show the table structure:
describe sample;

INSERT into table:
INSERT INTO sample 
(first_name, middle_initial, last_name, age, time_added, gpa)  
VALUES 
('Jake', 'G', 'Shields', 24, now(), 3.479);

Retrieve data:
SELECT * FROM sample;

comments powered by Disqus