mysql encrypted table name and columns - mysql

I'm making a C# application and i want to encrypt table name and column name
Now my query looks like this:
CREATE TABLE 'fmx8ttwCrwiloPwF0cJzRA==' ('0W7pGx8jrh2+NiWh57iUhA==' INT auto_increment, 'nAra1k/bvX0hVmIgB6cVdw==' INT, 'ypDGo22BnDzv6lkYrRVOvg==' LONGTEXT) DEFAULT CHARSET=utf8
What is wrong with it?
How can I fix it?
I need to use special charset...

Related

SQL create an alias or typedef for varchar(20)

I am trying to standardize our mysql table creation script, we have several similar names that perform similar function in several tables.
Think the column name is owner, creator, updater and it appears in multiple tables. But some tables are using the datatype as varchar(20), some are using varchar(50) and some varchar(100).
Is there a way to standardize these datatypes by using an alias or typedef of some kind ?
Example, instead of creating tables in my sql script create-tables.sql like :
create table A ( owner varchar(20) );
create table B ( creator varchar(50) );
create table C ( updater varchar(100) );
I do something like :
alias datatype_name is varchar(20)
create table A ( owner datatype_name );
create table B ( creator datatype_name );
create table C ( updater datatype_name );
Of course in MySQL these tables can use the data type varchar(20) , I am certainly not expecting the alias to carry forward from the creation sql script to mysql.

I have bad syntax I would like to know what my mistake is to pass it to mysql

ALTER TABLE `EscolaresadeudosBiblioteca`
ADD CONSTRAINT `DF_adeudosBiblioteca_adeudo`
DEFAULT ((1)) FOR `adeudo`
GO
I'm new to mysql, I'm trying to move from sql to mysql. I would like to know where I am wrong to correct the rest
DEFAULT is not a constraint but a property of a column. You can set it up as:
create table x1 (
id int,
status int
);
alter table x1 alter status set default 3;
See Safari Online.

MYSQL copy fields from one table's structure and add them to another tables

I've added some additional fields for my table in db. Now I need to have this additional fields in other few tables. So the question is - can I somehow copy those fields from source table and add them to another tables? Both mysql console and phpmyadmin variants woulbe be nice. Thanks!
A phpmyadmin variant would be to export the table's structure only (Export->Custom->Choose "Structure"). After that, you will get something like this in the exported SQL file:
CREATE TABLE `table` (
`id` int(10) NOT NULL,
`name` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
At that point, you can go ahead and remove the last line of the query and the parenthesis after the CREATE TABLE. Then, go ahead and substitute the [other_table] name and change the query to match the following:
ALTER TABLE `[other_table]`
ADD `id` int(10) NOT NULL,
ADD `name` varchar(50) DEFAULT NULL;
Notice how all I did was change CREATE to ALTER and add ADD before each field.
NOTE: This is not very useful on such a trivial example, but when dealing with large amounts of columns, it could prove somewhat useful.

How to create a column name with space in SQL Server

I want to create a column with a space in its name. In MySQL I just created this using back ticks, but in SQL Server that causes an error. Are there any possibilities to create a column name with a space?
I've tried the following but it doesn't work.
create table space_check
(
`roll num` int,
name varchar(50)
)
Can anybody tell me how to create this?
Use brackets in SQL-Server
create table space_check
(
[roll num] int,
name varchar(50)
)
Give the column name within Square brackets.
create table space_check
(
[roll num] int,
name varchar(50)
)
It was not a good practice. Try to create using underscore(roll_num) or caps(rollNum).
use bracket [ to create columns with spaces.
create table space_check
(
[roll num] int,
name varchar(50)
)
However it is not a good practice. Try using RollNum or rollNum or roll_num.

Rename a MySQL column containing ` in the column name

So, the other guy at work created a table with a column called:
Max(`abs_spg_20090430`.`ID`)
this is giving me an error now that I am trying to run a dump of the database on a different server.
I am trying to rename it, but
ALTER TABLE abs_spgID_20090504 CHANGE Max(`abs_spg_20090430`.`ID`) id bigint default null;
as well as
ALTER TABLE abs_spgID_20090504 CHANGE `Max(`abs_spg_20090430`.`ID`)` id bigint default null;
give me an error. Does any of you friendly people have a hint? Many thanks!
you need to quote your quotes and the column too, e.g:
ALTER TABLE abs_spgID_20090504 CHANGE `Max(``abs_spg_20090430``.``ID``)` id BIGINT DEFAULT NULL;