Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Articles Tagged ‘mysql’

MySQL Commands – Part 5

Monday, July 14th, 2014 by Servage
qqAUTO_INCREMENT data type As its name implies, a column given this data type will set the value of its contents to that of the column entry in the previously inserted row, plus 1. This is your introduction to the ALTER command, which is very similar to CREATE. ALTER operates on an existing table, and can add, change, or delete columns. Our example adds a column named id with the following characteristics: INT UNSIGNED Makes the column take an integer large enough for you to store more than four billion records in the table. NOT NULL Ensures that every column has a value. Many programmers use NULL in a field to indicate that the field doesn’t have a value, but ...

MySQL Commands – Part 4

Monday, July 7th, 2014 by Servage
BM8T0Numeric data types MySQL supports various numeric data types, from a single byte up to double-precision floating-point numbers. Although the most memory that a numeric field can use up is eight bytes, you are well advised to choose the smallest data type that will adequately handle the largest value you expect. This will help keep your databases small and quickly accessible. To specify whether a data type is signed or unsigned, use the UNSIGNED qualifier. The following example creates a table called tablename with a field in it called fieldname of the data type UNSIGNED INTEGER: CREATE TABLE tablename (fieldname INT UNSIGNED); When creating a numeric field, you can also pass an optional number as ...

MySQL Commands – Part 3

Saturday, July 5th, 2014 by Servage
php-explorer-tab-search With this article we continue our series about essential MySQL Commands. Data Types (cont.) The year field, however, has more predictable values, so instead of VARCHAR we use the more efficient CHAR(4) data type. The parameter of 4 allows for four bytes of data, supporting all years from –999 to 9999. You could, of course, just store two-digit values for the year, but if your data is going to still be needed in the following century, or may otherwise wrap around, it will have to be sanitized first—much like the “millennium bug” that would have caused dates beginning on January 1, 2000, to be treated as 1900 on many of the world’s biggest ...

MySQL Commands – Part 2

Wednesday, June 18th, 2014 by Servage
www Let us continue from part 1. You also need to be aware that if you create a new user but do not specify an IDENTIFIED BY clause, the user will have no password, a situation that is very insecure and should be avoided. Creating a table At this point, you should now be logged in to MySQL with ALL privileges granted for the database publications (or a database that was created for you)—you’re ready to create your first table. Make sure that database is in use by typing the following (replacing publications with the name of your database if it is different): USE publications; Now enter the commands one line at a time. Creating a table called ...

MySQL Commands – Part 1

Monday, June 16th, 2014 by Servage
wThis will be an intro to the most important MySQL commands for your everyday projects. I’ll cover most of these as we proceed, but first, you need to remember a couple of points about MySQL commands: • SQL commands and keywords are case-insensitive. CREATE, create, and CrEaTe all mean the same thing. However, for the sake of clarity, the recommended style is to use uppercase. • Table names are case-insensitive on Windows, but case-sensitive on Linux and OS X. So, for portability purposes, you should always choose a case and stick to it. The recommended style is to use lowercase or mixed upper- and lowercase for table names. Creating a database Get the ball rolling by issuing ...

Using Database in Web Development-Part 8

Friday, June 6th, 2014 by Servage
dd What about Sorting? What if I want to sort my data? Do I have to write some customized sorting script to sort the data after I get it out? Thankfully, no. SQL has already done that work for you. Here's an example of how you would retrieve and sort all of the last names in our "contacts" table that we created way back in Parts 1 and 2:   SELECT *   FROM table   ORDER BY last_name; How's that for easy? The ORDER BY clause tells the DBMS to perform a sort on the data using the "last_name" column. Now the data that you get out will be pre-sorted by last name from A to Z. So, ...

Using Database in Web Development – Part 6

Monday, June 2nd, 2014 by Servage
c Now we have tables with stuff in them. The next logical step is getting stuff back out. In this lesson you will learn about the most used statement in SQL, the SELECT. What is a SELECT statement?   So, what does SELECT do? Very simply, it tells the DBMS that you want to get some data out of the database. So, how does it work? SELECT can range from very simple to painfully complex. With SELECT there are a whole host of different options available to you that will allow you specify, calculate and arrange your data in an infinite number of ways. Using a SELECT statement obviously begins with the SELECT command. Next, you will ...

Using Database in Web Development-Part 5

Wednesday, May 14th, 2014 by Servage
b What you are learning here is merely the tip of the proverbial iceberg. There is much more to learning about databases but this will give you a good foundation to build on. There is always more to learn and, as usual, nothing stays the same. Database FAQs So, what's the deal with the semicolon? The semicolon at the end of a statement simply tells the DBMS that you are done with that statement and it should process it now. DBMSs can very greatly when it comes to designating the end of a statement so be sure to check your DBMS and see which one is right for you. Isn't there a better way to ...

Using Database in Web Development-Part 4

Monday, May 12th, 2014 by Servage
a Alright, we're making some progress now. You have a database and you've created some tables. What about putting some data into the tables? What is an INSERT statement?  I'm sure that it's not hard to guess what the INSERT statement does. However, how it works will probably need a little explanation. In order to use INSERT you will need to learn about a couple of other important keywords, INTO and VALUES. Let's start with INTO. In order for the DBMS to know where to put the data that you are adding it has to know what table you want the data to be added to. Using the "contact" table that we created in part ...

Using Database in Web Development-Part 3

Saturday, May 3rd, 2014 by Servage
3 Now we'll use some pretty pictures to illustrate the process of creating a database and table in Access. There are many other DBMS's out there besides Access, so be sure to do a little homework and download some demos before you decide which DBMS is right for you. Once Access has loaded the first order of business is to create a blank database. Once you have selected the blank database option, you will need to give your database a name and a location to save it. Now that you have your database created, select the Create Table in Design View option in the middle window by double-clicking on it....