Viewers: in countries Watching now:
MySQL is by far the most popular database management system for small- to medium-sized web projects. In this course, Bill Weinman provides clear, concise tutorials that guide you through creating and maintaining a MySQL database of your own. Bill explores the basic syntax, using SQL statements to create, insert, update, and delete data from your tables. He also covers creating a new database from scratch, as well as data types, transactions, subselects, views, and stored routines. Plus, learn about the multi-platform PHP PDO interface that will help you connect your database to web applications.
Support for a bit type began with MySQL version 5.03. Before that the bit type was simply mapped to tiny int and didn't work very well. Because of this legacy, it's gotten a bad reputation. But as of MySQL 5.6, it works just fine, and it can be useful. So we're going to start with the scratch database here. And we're just going to create a simple table. I'll start as always with the Drop Table If Exists.
And we'll create a table and we'll give it a ID column, and a couple of BIT columns. So I have here a three-bit column and a five-bit column, together three and five is eight, so these two columns are going to just take up eight bits. And they'll all be packed into one eight bit unit, into one eight bit byte. The Bit type is designed to conserve space as much as possible. You can define several columns of various bit lengths in a single table, and MySQL will pack these into as few units of storage as possible, usually on eight-bit boundaries.
So let's go ahead and add some values to this. Now we note that the largest decimal number you can express in three bits is a seven, so we'll say five, six and seven. And the largest number that you can express in five bits is a 31. And we'll just go one past that and see what happens if you try to put an eight in the three bit column or a 32 in the five bit column. And I'll just do a Select Star From Test.
I'll go ahead and run that. And so you notice that we have five, six, seven and then another seven, even though we inserted an eight, and we have a 29, 30, 31, 31 even though we inserted a 32. And in fact, if I try and put something outrageously large in here, it doesn't wrap around the bits or anything like that, it just gives you the maximum value. So, we still have 31s down there. So I'm going to go ahead and drop this table so that our database is back to its original condition.
The bit type is a convenient compact storage type for small values that can aggregate to take up as little space as possible.
There are currently no FAQs about MySQL Essential Training.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.