Learning machine learning? Try my machine learning flashcards or Machine Learning with Python Cookbook.
Show Column Information
Create Table
-- Create table called adventurers
CREATE TABLE adventurers (
-- string variable
name varchar(255),
-- integer variable
age int,
-- string variable
race varchar(255),
-- string variable
weapon varchar(255)
Insert Rows
-- Insert into the table adventurers
INSERT INTO adventurers (name, age, race, weapon)
VALUES ('Fjoak Doom-Wife', 28, 'Human', 'Axe'),
('Alooneric Cortte', 29, 'Elf', 'Bow'),
('Piperel Ramsay', 35, 'Elf', 'Sword'),
('Casimir Yardley', 14, 'Elf', 'Magic')
Show Column Information
-- Select column name, data type, and max character limit
SELECT column_name, data_type, character_maximum_length
-- From the database's schema
FROM INFORMATION_SCHEMA.COLUMNS
-- For the table adventurers
WHERE table_name = 'adventurers'
column_name | data_type | character_maximum_length |
---|---|---|
name | character varying | 255 |
age | integer | NULL |
race | character varying | 255 |
weapon | character varying | 255 |