The document details a MySQL session where a user attempts to create and manipulate a table named 'elect_bill' for managing electricity billing data. It includes various SQL commands, errors encountered due to syntax issues, and successful operations like table creation and data insertion. The final output shows the records in the 'elect_bill' table after updates to the amount and due date fields.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
17 views3 pages
Mysql prg1 Doc
The document details a MySQL session where a user attempts to create and manipulate a table named 'elect_bill' for managing electricity billing data. It includes various SQL commands, errors encountered due to syntax issues, and successful operations like table creation and data insertion. The final output shows the records in the 'elect_bill' table after updates to the amount and due date fields.
varchar2(25),date_billing date,units number(4)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar2(10),consumer_name varchar2(25),date_billing date,units number(4))' at line 1 mysql> mysql> create table elect_bill(RR_number varchar2(10),consumer_name varchar2(25),date_billing date,units number(4)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql> create table elect_bill(RR_number varchar2(10),consumer_name varchar2(25)' at line 1 mysql> create table elect_bill(RR_number varchar2(10),consumer_name varchar2(25),date_billing date,units number(4)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar2(10),consumer_name varchar2(25),date_billing date,units number(4))' at line 1 mysql> create table elect_bill(RR_number varchar(10),consumer_name varchar(25),date_billing date,units number(4)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'number(4))' at line 1 mysql> create table elect_bill(RR_number varchar(10),consumer_name varchar(25),date_billing date,units int); ERROR 1046 (3D000): No database selected mysql> CREATE TABLE elect_bill ( -> RR_number VARCHAR(10), -> consumer_name VARCHAR(25), -> date_billing DATE, -> units INT -> ); ERROR 1046 (3D000): No database selected mysql> CREATE DATABASE queries; Query OK, 1 row affected (0.15 sec)
+---------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+---------+-------+ | RR_number | varchar(10) | YES | | NULL | | | consumer_name | varchar(25) | YES | | NULL | | | date_billing | date | YES | | NULL | | | units | int | YES | | NULL | | +---------------+-------------+------+-----+---------+-------+ 4 rows in set (0.07 sec)
mysql> insert into elect_bill values('A1001','manj','2/2/2014',34);
ERROR 1292 (22007): Incorrect date value: '2/2/2014' for column 'date_billing' at row 1 mysql> sysdate -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sysdate' at line 1 mysql> insert into elect_bill values('A1001','manj','02-Nov-2024',34); ERROR 1292 (22007): Incorrect date value: '02-Nov-2024' for column 'date_billing' at row 1 mysql> INSERT INTO elect_bill VALUES ('A1001', 'manj', STR_TO_DATE('02-Nov-2024', '%d-%b-%Y'), 34); Query OK, 1 row affected (0.17 sec)
mysql> INSERT INTO elect_bill VALUES ('A1001', 'manj', '2024-11-02', 34);
Query OK, 1 row affected (0.13 sec)
mysql> alter tale elect_bill add(amount number(6,2),due_date date);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tale elect_bill add(amount number(6,2),due_date date)' at line 1 mysql> alter table elect_bill add(amount number(6,2),due_date date); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'number(6,2),due_date date)' at line 1 mysql> alter table elect_bill add(amount int(6,2),due_date date); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',2),due_date date)' at line 1 mysql> ALTER TABLE elect_bill ADD (amount DECIMAL(6,2), due_date DATE); Query OK, 0 rows affected (0.30 sec) Records: 0 Duplicates: 0 Warnings: 0
mysql> desc elect_bill;
+---------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ | RR_number | varchar(10) | YES | | NULL | | | consumer_name | varchar(25) | YES | | NULL | | | date_billing | date | YES | | NULL | | | units | int | YES | | NULL | | | amount | decimal(6,2) | YES | | NULL | | | due_date | date | YES | | NULL | | +---------------+--------------+------+-----+---------+-------+ 6 rows in set (0.00 sec)