Is it possible to store an image, pdf, video, etc. in a SQL database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bakertaylor28
    New Member
    • Feb 2021
    • 45

    Is it possible to store an image, pdf, video, etc. in a SQL database?

    Is it possible to store a file (such as an image, pdf file, mp4 video file, etc.) in a SQL database, and then call that file back out of the database to use in web content? If so, how do you do this?
  • Niheel
    Recognized Expert Moderator Top Contributor
    • Jul 2005
    • 2433

    #2
    Yes. In most SQL databases you can store the images, pdfs and videos directly into the database in their binary format.

    To do this you would use a BLOB ( binary large object ) column type to store the file data in.

    Example table:
    Code:
    mysql> create table product ( 
    product_id BIGINT PRIMARY KEY,
    product_name VARCHAR(50) NOT NULL, 
    photo BLOB NOT NULL
    ) Engine = InnoDB;
    niheel @ bytes

    Comment

    Working...