Sponsored Content
Full Discussion: Mysql CHAR vs VARCHAR
Special Forums UNIX and Linux Applications Mysql CHAR vs VARCHAR Post 302144157 by nadamson on Tuesday 6th of November 2007 12:57:40 PM
Old 11-06-2007
RE: Mysql CHAR vs VARCHAR

Actually a VARCHAR(10) will only allow up to 10 characters and no more.

The main difference between CHAR and VARCHAR is how data is stored in the column. The length of a CHAR column is fixed and when CHAR values are stored, they are right-padded with spaces to the specified length. In contrast to CHAR, VARCHAR values are stored using only as many characters as are needed.

Please see the MySQL docs for more details:
MySQL AB :: MySQL 5.0 Reference Manual :: 10.4.1 The CHAR and VARCHAR Types

Cheers!
Nate
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace any char with newline char.

Hi, How to replace any character in a file with a newline character using sed .. Ex: To replace ',' with newline Input: abcd,efgh,ijkl,mnop Output: abcd efgh ijkl mnop Thnx in advance. Regards, Sasidhar (5 Replies)
Discussion started by: mightysam
5 Replies

2. Programming

Adding a single char to a char pointer.

Hello, I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it: char* getext(char *file) { char *extension; int i, j;... (5 Replies)
Discussion started by: pallak7
5 Replies

3. UNIX for Advanced & Expert Users

sorting of varchar columns

Hi , I need to sort a file based on multiple columns All the columns are of varchar type can any one give me the command to sort for varchar columns? Thanks (3 Replies)
Discussion started by: laxmi131
3 Replies

4. Programming

concat const char * with char *

hello everybody! i have aproblem! i dont know how to concatenate const char* with char const char *buffer; char *b; sprintf(b,"result.txt"); strcat(buffer,b); thanx in advance (4 Replies)
Discussion started by: nicos
4 Replies

5. Programming

error: invalid conversion from ‘const char*’ to ‘char*’

Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially): xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’: xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’ The same error with all c++ constructors - gcc 4.4.4. If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies

6. UNIX and Linux Applications

MySQL Daemon failed to start - no mysql.sock file

After doing a yum install mysql mysql-server on Fedora 14 I wasn't able to fully install the packages correctly. It installed MySQL 5.1. I was getting the following error when running the: mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)... (3 Replies)
Discussion started by: jastanle84
3 Replies

7. Programming

Invalid conversion from char* to char

Pointers are seeming to get the best of me and I get that error in my program. Here is the code #include <stdio.h> #include <stdlib.h> #include <string.h> #define REPORTHEADING1 " Employee Pay Hours Gross Tax Net\n" #define REPORTHEADING2 " Name ... (1 Reply)
Discussion started by: Plum
1 Replies

8. UNIX for Beginners Questions & Answers

How to get number on file exclude varchar?

hallo, yould you guys help me? im using bash script i have file getnumber.csv cat getnumber.csv 234198 654639 eht4v4 453nbddme 43 455fr i try this cat getnumber.csv | sed 's/*//g' but the result is : 234198 (5 Replies)
Discussion started by: kivale
5 Replies
CUBRID_ROLLBACK(3)							 1							CUBRID_ROLLBACK(3)

cubrid_rollback - Roll back a transaction

SYNOPSIS
bool cubrid_rollback (resource $conn_identifier) DESCRIPTION
The cubrid_rollback(3) function executes rollback on the transaction pointed by $conn_identifier, currently in progress. Connection to server is closed after calling cubrid_rollback(3). Connection handle, however, is still valid. PARAMETERS
o $conn_identifier -Connection identifier. RETURN VALUES
TRUE, when process is successful. FALSE, when process is unsuccessful. EXAMPLES
Example #1 cubrid_rollback(3) example <?php $conn = cubrid_connect("127.0.0.1", 33000, "demodb", "dba"); cubrid_set_autocommit($conn,false); @cubrid_execute($conn, "DROP TABLE publishers"); $sql = <<<EOD CREATE TABLE publishers( pub_id CHAR(3), pub_name VARCHAR(20), city VARCHAR(15), state CHAR(2), country VARCHAR(15) ) EOD; if (!cubrid_execute($conn, $sql)) { printf("Error facility: %d Error code: %d Error msg: %s ", cubrid_error_code_facility(), cubrid_error_code(), cubrid_error_msg()); cubrid_disconnect($conn); exit; } $req = cubrid_prepare($conn, "INSERT INTO publishers VALUES(?, ?, ?, ?, ?)"); $id_list = array("P01", "P02", "P03", "P04"); $name_list = array("Abatis Publishers", "Core Dump Books", "Schadenfreude Press", "Tenterhooks Press"); $city_list = array("New York", "San Francisco", "Hamburg", "Berkeley"); $state_list = array("NY", "CA", NULL, "CA"); $country_list = array("USA", "USA", "Germany", "USA"); for ($i = 0, $size = count($id_list); $i < $size; $i++) { cubrid_bind($req, 1, $id_list[$i]); cubrid_bind($req, 2, $name_list[$i]); cubrid_bind($req, 3, $city_list[$i]); cubrid_bind($req, 4, $state_list[$i]); cubrid_bind($req, 5, $country_list[$i]); if (!($ret = cubrid_execute($req))) { break; } } if (!$ret) { cubrid_rollback($conn); } else { cubrid_commit($conn); $req = cubrid_execute($conn, "SELECT * FROM publishers"); while ($result = cubrid_fetch_assoc($req)) { printf("%-3s %-20s %-15s %-3s %-15s ", $result["pub_id"], $result["pub_name"], $result["city"], $result["state"], $result["country"]); } } cubrid_disconnect($conn); ?> The above example will output: P01 Abatis Publishers New York NY USA P02 Core Dump Books San Francisco CA USA P03 Schadenfreude Press Hamburg Germany P04 Tenterhooks Press Berkeley CA USA SEE ALSO
cubrid_commit(3), cubrid_disconnect(3). PHP Documentation Group CUBRID_ROLLBACK(3)
All times are GMT -4. The time now is 04:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy