Jump to content
xisto Community
Blessed

Some Mysql Basics

Recommended Posts

Greetings
this tutorial will show you some mysql basics..
MySQL is one of the most used database.

a simple config file
at the top add this

<?php?> after <?php add$username= "root"; // Username that has access to your database$password= ""; //Password that has access to your database$host = "localhost"; // The host where the database is (mostly this is localhost)$db = "databasename"; // The name of the database where you want to work with//connect to the databasemysql_connect($host,$username,$password);mysql_select_db($db);

Some basic statements

Now we're going to see the following statements:

- CREATE
- SELECT
- INSERT
- UPDATE
- DROP
- ALTER
- DELETE

CREATE:
CREATE. You do that like this:
CREATE TABLE tablename(fieldname datatype,fieldname datatype,);

+-----------------------------------------------------
These are the different datatypes you can choose from:

Datatype / Explanation

TINYINT Integer from -128 tot 127SMALLINT Integer from -32.768 tot 32.767
MEDIUMINT Integer from -8.388.608 tot 8.388.607
INT Integer from -2.147.483.648 tot 2.147.483.647
BIGINT Integer from -9.223.372.036.854.775.808 till 9.223.372.036.854.775.807
FLOAT number with a ','
DOUBLE number with a ',' but with is more specifier
DATE UNIX-date
DATETIME UNIX-date and time
CHAR String with a number of characters
VARCHAR String with a number of characters
TINYBLOB Little BLOB-field
TINYTEXT Little TEXT-field
TEXT Textfield without restrictions, comes in handy for big documents
BLOB (Binairy Large OBject) The same as TEXT but only with BINARY DATA
LONGBLOB Huge BLOB field
LONGTEXT Huge TEXT field
ENUM No explanation
SET No explanation

+-----------------------------------------------------



I will update the post later to add more basic things

Share this post


Link to post
Share on other sites

Some basic statements

 

Now we're going to see the following statements:

 

- CREATE

- SELECT

- INSERT

- UPDATE

- DROP

- ALTER

- DELETE


I think you forgot TURNICATE, to empty tables

 

EDIT: after a double check, it turned out to be TRUNCATE instead of TURNICATE. Sorry guys, hope i editted it soon enough!

Edited by Stenno (see edit history)

Share this post


Link to post
Share on other sites

can I use DROP to delete a table?
like:

DROP TABLE table_name


Yup, drop can be used for deleting tables, and it can even be used for deleting an entire database if you want.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.